WebPermissionAttribute Constructor (SecurityAction)


Initializes a new instance of the WebPermissionAttribute class with a value that specifies the security actions that can be performed on this class.

Namespace:   System.Net
Assembly:  System (in System.dll)

Public Sub New (
	action As SecurityAction


Type: System.Security.Permissions.SecurityAction

One of the SecurityAction values.

Exception Condition

action is not a valid SecurityAction value.

The SecurityAction value passed to this constructor specifies the allowable security actions that can be performed on this class.

The following example demonstrates how to apply WebPermissionAttribute to a method.

' Set the declarative security for the URI.
<WebPermission(SecurityAction.Deny, Connect := "http://www.contoso.com/")> _
Public Sub Connect()
   ' Throw an exception.	 
      Dim myWebRequest As HttpWebRequest = CType(WebRequest.Create("http://www.contoso.com"), HttpWebRequest)
   Catch e As Exception
      Console.WriteLine(("Exception : " + e.ToString()))
   End Try
End Sub 'Connect

.NET Framework
Available since 1.1
Return to top