WebPermission 생성자

정의

WebPermission 클래스의 새 인스턴스를 만듭니다.

오버로드

WebPermission()

WebPermission 클래스의 새 인스턴스를 만듭니다.

WebPermission(PermissionState)

모든 요청을 허용하거나 모든 요청을 거부하는 WebPermission 클래스의 새 인스턴스를 만듭니다.

WebPermission(NetworkAccess, String)

지정된 URI에 대한 지정된 액세스 권한을 사용하여 WebPermission 클래스의 새 인스턴스를 초기화합니다.

WebPermission(NetworkAccess, Regex)

지정된 URI 정규식에 대한 지정된 액세스 권한을 사용하여 WebPermission 클래스의 새 인스턴스를 초기화합니다.

WebPermission()

WebPermission 클래스의 새 인스턴스를 만듭니다.

public:
 WebPermission();
public WebPermission ();
Public Sub New ()

설명

WebPermission 클래스의 새 인스턴스를 만듭니다. 이 생성자는 권한을 부여하지 않는 빈 권한을 만듭니다.

추가 정보

적용 대상

WebPermission(PermissionState)

모든 요청을 허용하거나 모든 요청을 거부하는 WebPermission 클래스의 새 인스턴스를 만듭니다.

public:
 WebPermission(System::Security::Permissions::PermissionState state);
public WebPermission (System.Security.Permissions.PermissionState state);
new System.Net.WebPermission : System.Security.Permissions.PermissionState -> System.Net.WebPermission
Public Sub New (state As PermissionState)

매개 변수

state
PermissionState

PermissionState 값입니다.

예제

다음 예제에서는 인스턴스 WebPermission 를 만들고 특정 URL에 대한 액세스 권한을 부여합니다.

// Create a WebPermission instance.
WebPermission^ myWebPermission1 = gcnew WebPermission( PermissionState::None );

// Allow access to the first set of URL's.
myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.microsoft.com/default.htm" );
myWebPermission1->AddPermission( NetworkAccess::Connect, "http://www.msn.com" );

// Check whether all callers higher in the call stack have been granted the permissionor not.
myWebPermission1->Demand();
// Create a WebPermission instance.  
WebPermission myWebPermission1 = new WebPermission(PermissionState.None);

// Allow access to the first set of URL's.
myWebPermission1.AddPermission(NetworkAccess.Connect,"http://www.microsoft.com/default.htm");
myWebPermission1.AddPermission(NetworkAccess.Connect,"http://www.msn.com");

// Check whether all callers higher in the call stack have been granted the permissionor not.
myWebPermission1.Demand();
' Create a WebPermission instance.  
Dim myWebPermission1 As New WebPermission(PermissionState.None)

' Allow access to the first set of URL's.
myWebPermission1.AddPermission(NetworkAccess.Connect, "http://www.microsoft.com/default.htm")
myWebPermission1.AddPermission(NetworkAccess.Connect, "http://www.msn.com")

' Check whether all callers higher in the call stack have been granted the permissionor not.
myWebPermission1.Demand()

설명

매개 변수의 state 값은 PermissionState.None PermissionState.Unrestricted각각 모든 보안 변수에 대해 완전히 제한되거나 완전히 제한되지 않은 액세스를 생성합니다. 지정 PermissionState.None하는 경우 .을 사용하여 AddPermission개별 URI에 대한 액세스 권한을 부여할 수 있습니다.

추가 정보

적용 대상

WebPermission(NetworkAccess, String)

지정된 URI에 대한 지정된 액세스 권한을 사용하여 WebPermission 클래스의 새 인스턴스를 초기화합니다.

public:
 WebPermission(System::Net::NetworkAccess access, System::String ^ uriString);
public WebPermission (System.Net.NetworkAccess access, string uriString);
new System.Net.WebPermission : System.Net.NetworkAccess * string -> System.Net.WebPermission
Public Sub New (access As NetworkAccess, uriString As String)

매개 변수

access
NetworkAccess

지정된 URI에 대해 부여할 액세스 종류를 나타내는 NetworkAccess 값입니다. Accept는 로컬 리소스에 있는 인터넷에서 애플리케이션에 연결할 수 있음을 나타냅니다. Connect는 애플리케이션을 특정 인터넷 리소스에 연결할 수 있음을 나타냅니다.

uriString
String

액세스 권한이 부여되는 URI 문자열입니다.

예외

uriString이(가) null인 경우

예제

다음 예제에서는 지정된 URI에 WebPermission 대한 연결 권한이 있는 새 인스턴스를 만듭니다.

// Create a WebPermission::instance.
WebPermission^ myWebPermission1 = gcnew WebPermission( NetworkAccess::Connect,"http://www.contoso.com/default.htm" );
myWebPermission1->Demand();

// Create a WebPermission.instance.
WebPermission myWebPermission1 = new WebPermission(NetworkAccess.Connect,"http://www.contoso.com/default.htm");
myWebPermission1.Demand();
' Create a WebPermission.instance.
Dim myWebPermission1 As New WebPermission(NetworkAccess.Connect, "http://www.contoso.com/default.htm")
myWebPermission1.Demand()

설명

이 생성자는 매개 변수에 설명 uriString 된 URI를 사용하여 원격 호스트 연결을 만들거나 원격 호스트 연결을 수락할 수 있는 대상 권한을 초기화 WebPermission 하고 부여합니다.

추가 정보

적용 대상

WebPermission(NetworkAccess, Regex)

지정된 URI 정규식에 대한 지정된 액세스 권한을 사용하여 WebPermission 클래스의 새 인스턴스를 초기화합니다.

public:
 WebPermission(System::Net::NetworkAccess access, System::Text::RegularExpressions::Regex ^ uriRegex);
public WebPermission (System.Net.NetworkAccess access, System.Text.RegularExpressions.Regex uriRegex);
new System.Net.WebPermission : System.Net.NetworkAccess * System.Text.RegularExpressions.Regex -> System.Net.WebPermission
Public Sub New (access As NetworkAccess, uriRegex As Regex)

매개 변수

access
NetworkAccess

지정된 URI에 대해 부여할 액세스 종류를 나타내는 NetworkAccess 값입니다. Accept는 로컬 리소스에 있는 인터넷에서 애플리케이션에 연결할 수 있음을 나타냅니다. Connect는 애플리케이션을 특정 인터넷 리소스에 연결할 수 있음을 나타냅니다.

uriRegex
Regex

액세스 권한이 부여될 URI를 설명하는 정규식입니다.

예제

다음 예제에서는 지정된 System.Text.RegularExpressions.Regex에 대한 연결 권한이 있는 새 인스턴스 WebPermission 를 만듭니다.

// Create an instance of 'Regex' that accepts all URL's containing the host
// fragment 'www.contoso.com'.
Regex^ myRegex = gcnew Regex( "http://www.contoso.com/.*" );

// Create a WebPermission that gives the permissions to all the hosts containing
// the same fragment.
WebPermission^ myWebPermission = gcnew WebPermission( NetworkAccess::Connect,myRegex );

// Checks all callers higher in the call stack have been granted the permission.
myWebPermission->Demand();

 // Create an instance of 'Regex' that accepts all  URL's containing the host 
 // fragment 'www.contoso.com'.
 Regex myRegex = new Regex(@"http://www\.contoso\.com/.*");

// Create a WebPermission that gives the permissions to all the hosts containing 
// the same fragment.
WebPermission myWebPermission = new WebPermission(NetworkAccess.Connect,myRegex);
   
// Checks all callers higher in the call stack have been granted the permission.
myWebPermission.Demand();
'  Creates an instance of 'Regex' that accepts all  URL's containing the host fragment 'www.contoso.com'.
Dim myRegex As New Regex("http://www\.contoso\.com/.*")
  
   ' Creates a 'WebPermission' that gives the permissions to all the hosts containing same host fragment.
   Dim myWebPermission As New WebPermission(NetworkAccess.Connect, myRegex)
   
  '  Checks all callers higher in the call stack have been granted the permission.
  myWebPermission.Demand()

설명

이 생성자는 매개 변수에 설명 uriRegex 된 URI를 사용하여 원격 호스트 연결을 만들거나 원격 호스트 연결을 수락할 수 있는 대상 권한을 초기화 WebPermission 하고 부여합니다.

참고

, RegexOptions.CompiledRegexOptions.Singleline 플래그를 RegexOptions.IgnoreCase사용하여 만드는 uriRegex 것이 좋습니다.

참고

후보 URI 문자열은 두 가지 방법으로 관련 정규식(AcceptList 또는 ConnectList) 목록에 대해 확인됩니다. 먼저 후보 URI 문자열이 적절한 목록에 대해 검사됩니다. 그런 다음 일치하는 항목이 없으면 후보 URI 문자열이 a Uri 로 변환되고 적절한 목록에 대해 확인됩니다.

추가 정보

적용 대상