Controls rights to access HTTP Internet resources.
Assembly: System (in System.dll)
Thetype exposes the following members.
|WebPermission()||Creates a new instance of the class.|
|WebPermission(PermissionState)||Creates a new instance of the class that passes all demands or fails all demands.|
|WebPermission(NetworkAccess, String)||Initializes a new instance of the class with the specified access rights for the specified URI.|
|WebPermission(NetworkAccess, Regex)||Initializes a new instance of the class with the specified access rights for the specified URI regular expression.|
|AcceptList||This property returns an enumeration of a single accept permissions held by this . The possible objects types contained in the returned enumeration are String and System.Text.RegularExpressions.Regex.|
|ConnectList||This property returns an enumeration of a single connect permissions held by this . The possible objects types contained in the returned enumeration are String and System.Text.RegularExpressions.Regex.|
|AddPermission(NetworkAccess, String)||Adds the specified URI string with the specified access rights to the current .|
|AddPermission(NetworkAccess, Regex)||Adds the specified URI with the specified access rights to the current .|
|Assert||Declares that the calling code can access the resource protected by a permission demand through the code that calls this method, even if callers higher in the stack have not been granted permission to access the resource. Using Assert can create security issues. (Inherited from CodeAccessPermission.)|
|Copy||Creates a copy of a . (Overrides CodeAccessPermission.Copy().)|
|Demand||Forces a SecurityException at run time if all callers higher in the call stack have not been granted the permission specified by the current instance. (Inherited from CodeAccessPermission.)|
|Deny||Obsolete. Prevents callers higher in the call stack from using the code that calls this method to access the resource specified by the current instance. (Inherited from CodeAccessPermission.)|
|Equals||Determines whether the specified CodeAccessPermission object is equal to the current CodeAccessPermission. (Inherited from CodeAccessPermission.)|
|FromXml||Reconstructs a from an XML encoding. (Overrides CodeAccessPermission.FromXml(SecurityElement).)|
|GetHashCode||Gets a hash code for the CodeAccessPermission object that is suitable for use in hashing algorithms and data structures such as a hash table. (Inherited from CodeAccessPermission.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|Intersect||Returns the logical intersection of two instances. (Overrides CodeAccessPermission.Intersect(IPermission).)|
|IsSubsetOf||Determines whether the current is a subset of the specified object. (Overrides CodeAccessPermission.IsSubsetOf(IPermission).)|
|IsUnrestricted||Checks the overall permission state of the .|
|PermitOnly||Prevents callers higher in the call stack from using the code that calls this method to access all resources except for the resource specified by the current instance. (Inherited from CodeAccessPermission.)|
|ToString||Creates and returns a string representation of the current permission object. (Inherited from CodeAccessPermission.)|
|ToXml||Creates an XML encoding of a and its current state. (Overrides CodeAccessPermission.ToXml().)|
|Union||Returns the logical union between two instances of the class. (Overrides CodeAccessPermission.Union(IPermission).)|
provides a set of methods and properties to control access to Internet resources. You can use a to provide either restricted or unrestricted access to your resource, based on the PermissionState that is set when the is created.
Create a instance by calling its constructor using one of the following sets of parameters:
A NetworkAccess specifier and URI regular expression.
The ConnectList and AcceptList hold the URIs to which you have granted access permission. To add a URI to either of these lists, use AddPermission. If you pass Accept as the NetworkAccess parameter, the URI will be added to the AcceptList. will allow connections to your target class with URIs matching the AcceptList.
To deny access to an Internet resource, you must deny access to all the possible paths to that resource. This requires calling WebPermission.WebPermission with state parameter set to Deny. A better approach is to allow access to the specific resource only. For more information about this subject, refer to the Using the Deny Method topic.
You need to deny access using only the resource canonical path. There is no need to use all the path's syntactical variations.
User name and default port information is stripped from the Uri before the comparison with the regular expression argument that is supplied to the WebPermission(NetworkAccess, Regex) constructor. If the regular expression contains user information or the default port number, then all incoming Uris will fail to match the regular expression.
The following example demonstrates how to create a new instance of using a Regex. Additional hosts are added to the connect and accept list of . Finally, the connect and accept list are displayed to the console.
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.