TrustLevel 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
定義特定安全性層級對具名原則檔的對應。 此類別無法獲得繼承。
public ref class TrustLevel sealed : System::Configuration::ConfigurationElement
public sealed class TrustLevel : System.Configuration.ConfigurationElement
type TrustLevel = class
inherit ConfigurationElement
Public NotInheritable Class TrustLevel
Inherits ConfigurationElement
- 繼承
範例
下列程式碼範例示範如何使用 TrustLevel 類型。
#region Using directives
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Web;
using System.Web.Configuration;
#endregion
namespace Samples.Aspnet.SystemWebConfiguration
{
class UsingTrustLevel
{
static void Main(string[] args)
{
try
{
// Display title.
Console.WriteLine("ASP.NET TrustLevel Info");
Console.WriteLine();
// Instantiate a new TrustLevel object.
TrustLevel TrustLevel1 =
new TrustLevel("myLevel1", "myLevel1.config");
// Get the Name of the TrustLevel object.
Console.WriteLine("Name: {0}", TrustLevel1.Name);
// Instantiate a new TrustLevel object.
TrustLevel TrustLevel2 =
new TrustLevel("myLevel2", "myLevel2.config");
// Get the PolicyFile of the TrustLevel object.
Console.WriteLine("PolicyFile: {0}", TrustLevel2.PolicyFile);
}
catch (Exception e)
{
// Unknown error.
Console.WriteLine(e.ToString());
}
// Display and wait.
Console.ReadLine();
}
}
}
Imports System.Collections.Generic
Imports System.Text
Imports System.Configuration
Imports System.Web
Imports System.Web.Configuration
Namespace Samples.Aspnet.SystemWebConfiguration
Class UsingTrustLevel
Public Shared Sub Main()
Try
' Display title.
Console.WriteLine("ASP.NET TrustLevel Info")
Console.WriteLine()
' Instantiate a new TrustLevel object.
Dim TrustLevel1 As TrustLevel = _
New TrustLevel("myLevel1", "myLevel1.config")
' Get the Name of the TrustLevel object.
Console.WriteLine("Name: {0}", TrustLevel1.Name)
' Instantiate a new TrustLevel object.
Dim TrustLevel2 As TrustLevel = _
New TrustLevel("myLevel2", "myLevel2.config")
' Get the PolicyFile of the TrustLevel object.
Console.WriteLine("PolicyFile: {0}", TrustLevel2.PolicyFile)
Catch e As Exception
' Unknown error.
Console.WriteLine(e.ToString())
End Try
' Display and wait.
Console.ReadLine()
End Sub
End Class
End Namespace
備註
您可以建立自己的具名 TrustLevel 物件,以擴充 Web 應用程式的安全性,該物件會對應至 屬性所 policyFile
指定的檔案。
建構函式
TrustLevel(String, String) |
根據提供的值,建立初始化的 TrustLevel 類別執行個體,該值會定義特定安全性層級對具名原則檔的對應。 |