Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

WebPermission.AddPermission Method

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

Overload List

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

[Visual Basic] Overloads Public Sub AddPermission(NetworkAccess, Regex)
[C#] public void AddPermission(NetworkAccess, Regex);
[C++] public: void AddPermission(NetworkAccess, Regex*);
[JScript] public function AddPermission(NetworkAccess, Regex);

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

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

Example

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

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of AddPermission. For other examples that might be available, see the individual overload topics.
[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.

See Also

WebPermission Class | WebPermission Members | System.Net Namespace

Show:
© 2015 Microsoft