Export (0) Print
Expand All

WebPermission Constructor (PermissionState)

.NET Framework 1.1

Creates a new instance of the WebPermission class that passes all demands or fails all demands.

[Visual Basic]
Public Sub New( _
   ByVal state As PermissionState _
)
[C#]
public WebPermission(
   PermissionState state
);
[C++]
public: WebPermission(
   PermissionState state
);
[JScript]
public function WebPermission(
   state : PermissionState
);

Parameters

state
A PermissionState value.

Remarks

The value of the state parameter is either PermissionState.None or PermissionState.Unrestricted, respectively yielding fully restricted or fully unrestricted access to all security variables. If you specify PermissionState.None, then you may give access to individual URI's using AddPermission.

Example

[Visual Basic, C#, C++] The following example creates an instance of WebPermission and gives access rights to specific URLs.

[Visual Basic] 
' 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()


[C#] 
// 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();


[C++] 
// Create a WebPermission instance.
WebPermission* myWebPermission1 = new WebPermission(PermissionState::None);

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

// Check whether all callers higher in the call stack have been granted the permissionor not.
myWebPermission1->Demand();

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

See Also

WebPermission Class | WebPermission Members | System.Net Namespace | WebPermission Constructor Overload List | Unrestricted

Show:
© 2015 Microsoft