Export (0) Print
Expand All

WebPermission Constructor (NetworkAccess, String)

.NET Framework 1.1

Initializes a new instance of the WebPermission class with the specified access rights for the specified URI.

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

Parameters

access
A NetworkAccess value indicating what kind of access to grant to the specified URI. Accept indicates that the application is allowed to accept connections from the Internet on a local resource. Connect indicates that the application is allowed to connect to specific Internet resources.
uriString
A URI string to which access rights are granted.

Exceptions

Exception Type Condition
ArgumentNullException uriString is a null reference (Nothing in Visual Basic).

Remarks

This constructor initializes a WebPermission and grants its target permission to either make a remote host connection or to accept a remote host connection using the URI described by the uriString parameter.

Example

[Visual Basic, C#, C++] The following example creates a new instance of WebPermission with connect rights for the specified URI.

[Visual Basic] 
' Create a WebPermission.instance.
Dim myWebPermission1 As New WebPermission(NetworkAccess.Connect, "http://www.contoso.com/default.htm")
myWebPermission1.Demand()


[C#] 

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


[C++] 
// Create a WebPermission::instance.
WebPermission* myWebPermission1 = new WebPermission(NetworkAccess::Connect, S"http://www.contoso.com/default.htm");
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 | Regex

Show:
© 2014 Microsoft