Share via


Web and Socket Permissions

Internet security for applications using the System.Net namespace is provided by the WebPermission and SocketPermission classes. The WebPermission class controls an application's right to request data from a URI or to serve a URI to the Internet. The SocketPermission class controls an application's right to use a Socket to accept data on a local port or to contact remote devices using a transport protocol at another address, based on the host, port number, and transport protocol of the socket.

Which permission class you use depends on your application type. Applications that use WebRequest and its descendants should use the WebPermission class to manage permissions. Applications that use socket-level access should use the SocketPermission class to manage permissions.

WebPermission and SocketPermission define two permissions: accept and connect. Accept grants the application the right to answer an incoming connection from another party. Connect grants the application the right to initiate a connection to another party.

For SocketPermission instances, accept means that an application can accept incoming connections on a local transport address; connect means that an application can connect to some remote (or local) transport address.

For WebPermission instances, accept means that an application can export the URI controlled by the WebPermission to the world; connect means that an application can access that URI (whether it is remote or local).

See Also

Securing Applications | Internet Security