System.Net.WebPermission Class

Controls rights to access HTTP Internet resources.

See Also: WebPermission Members

Syntax

[System.MonoTODO("Most private members that include functionallity are not implemented!")]
public sealed class WebPermission : System.Security.CodeAccessPermission, System.Security.Permissions.IUnrestrictedPermission

Remarks

System.Net.WebPermission provides a set of methods and properties to control access to Internet resources. You can use a System.Net.WebPermission to provide either restricted or unrestricted access to your resource, based on the System.Security.Permissions.PermissionState that is set when the System.Net.WebPermission is created.

Create a System.Net.WebPermission instance by calling its constructor using one of the following sets of parameters:

The WebPermission.ConnectList and WebPermission.AcceptList hold the URIs to which you have granted access permission. To add a URI to either of these lists, use WebPermission.AddPermission(NetworkAccess, string). If you pass NetworkAccess.Accept as the System.Net.NetworkAccess parameter, the URI will be added to the WebPermission.AcceptList. System.Net.WebPermission will allow connections to your target class with URIs matching the WebPermission.AcceptList.

Note:

To deny access to an Internet resource, you must deny access to all the possible paths to that resource. This requires calling WebPermission.#ctor(System.Security.Permissions.PermissionState) with state parameter set to System.Security.CodeAccessPermission.Deny. A better approach is to allow access to the specific resource only. For more information about this subject, refer to the [<topic://cpcondeny>] topic.

Note:

You need to deny access using only the resource canonical path. There is no need to use all the path's syntactical variations.

Note:

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.#ctor(NetworkAccess, System.Text.RegularExpressions.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.

Thread Safety

All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 1.0.x.x, 1.0.5000.0, 2.0.0.0, 4.0.0.0