Export (0) Print
Expand All

WebPermission.AddPermission Method (NetworkAccess, String)

.NET Framework 1.1

Adds the specified URI string with the specified access rights to the current WebPermission.

[Visual Basic]
Overloads Public Sub AddPermission( _
   ByVal access As NetworkAccess, _
   ByVal uriString As String _
)
[C#]
public void AddPermission(
 NetworkAccess access,
 string uriString
);
[C++]
public: void AddPermission(
 NetworkAccess access,
 String* uriString
);
[JScript]
public function AddPermission(
   access : NetworkAccess,
 uriString : String
);

Parameters

access
A NetworkAccess specifying the access rights granted to the URI
uriString
A string describing the URI to which access rights are granted.

Exceptions

Exception Type Condition
ArgumentNullException uriString is null.

Remarks

If you have specified None as the PermissionState, use AddPermission to permit the use of uriString in the target class. The way that uriString can be used by the target class is specified by access. Specify Accept as the access parameter to add the URI specified by the uriString parameter to the list of URI accept strings, or specify Connect as the access parameter to add the URI to the list of URI connect strings.

Note   Calling AddPermission on Unrestricted WebPermission will have no effect, as permission is granted to all URI's.

Example

[Visual Basic, C#, C++] The following example demonstrates how to add access rights to particular URL strings.

[Visual Basic] 
' Allow access to the first set of resources.
myWebPermission1.AddPermission(NetworkAccess.Connect, "http://www.contoso.com/default.htm")
myWebPermission1.AddPermission(NetworkAccess.Connect, "http://www.adventure-works.com/default.htm")

' Check whether if the callers higher in the call stack have been granted 
' access permissions.
myWebPermission1.Demand()


[C#] 

    // Allow access to the first set of resources.
    myWebPermission1.AddPermission(NetworkAccess.Connect,"http://www.contoso.com/default.htm");
    myWebPermission1.AddPermission(NetworkAccess.Connect,"http://www.adventure-works.com/default.htm");
  
    // Check whether if the callers higher in the call stack have been granted 
    // access permissions.
    myWebPermission1.Demand();


[C++] 
// Allow access to the first set of resources.
myWebPermission1->AddPermission(NetworkAccess::Connect,
   S"http://www.contoso.com/default.htm");
myWebPermission1->AddPermission(NetworkAccess::Connect,
   S"http://www.adventure-works.com/default.htm");

// Check whether if the callers higher in the call stack have been granted
// access permissions.
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

See Also

WebPermission Class | WebPermission Members | System.Net Namespace | WebPermission.AddPermission Overload List | NetworkAccess

Show:
© 2014 Microsoft