Click or drag to resize
IWebServer Interface
The interface for objects that can serve requests for web pages.

Namespace: VirtualRadar.Interface.WebServer
Assembly: VirtualRadar.Interface (in VirtualRadar.Interface.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public interface IWebServer : IBackgroundThreadExceptionCatcher, 
	IDisposable

The IWebServer type exposes the following members.

Properties
  NameDescription
Public propertyAuthenticationScheme
Gets or sets the authentication scheme to use.
Public propertyCacheCredentials
Gets or sets a value indicating that authentication credentials can be cached by the server.
Public propertyExternalAddress
Gets the address of the web server on the public Internet (e.g. http://12.13.14.15:8080/Root).
Public propertyExternalIPAddress
Gets or sets the IP address of the local machine on the public internet. Optional, used to build ExternalAddress.
Public propertyExternalPort
Gets or sets the port number that public Internet clients can connect to in order to reach this machine. Optional, used to build ExternalAddress.
Public propertyLocalAddress
Gets the local address of the web server (e.g. http://127.0.0.1:8090/Root).
Public propertyNetworkAddress
Gets the address of the web server on the LAN (e.g. http://192.168.0.1:8090/Root).
Public propertyNetworkIPAddress
Gets the IP address of the current machine on the LAN (e.g. 192.168.0.1).
Public propertyOnline
Gets or sets a value indicating that the server is online.
Public propertyPort
Gets or sets the port number to listen to.
Public propertyPortText
Gets the Port number as a string suitable for use in a URL.
Public propertyPrefix
Gets the prefix that describes the combination of root and port.
Public propertyProvider
Gets or sets the provider used to wrap bits of the .NET framework.
Public propertyRoot
Gets or sets the root of the web site that the server will listen to.
Top
Methods
  NameDescription
Public methodAddAdministratorPath
Tells the server that all access to this path must be authenticated and that the user must be configured as an administrator.
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
(Inherited from IDisposable.)
Public methodGetAdministratorPaths
Returns the paths that have been marked as requiring authentication.
Public methodGetRestrictedPathsMap
Returns a map of restricted paths to the Access describing which IPAddresses can access the path.
Public methodRemoveAdministratorPath
Tells the server that anyone can now access this path.
Public methodResetCredentialCache
Clears the cache of credentials held by the server - see CacheCredentials.
Public methodSetRestrictedPath
Sets access on a restricted path. If access is null then the restrictions are removed from the path.
Top
Events
  NameDescription
Public eventAfterRequestReceived
Raised on a background thread when the web server receives a request from a browser. Called after RequestReceived is raised.
Public eventAuthenticationRequired
Raised when the AuthenticationScheme is not 'None' and the browser has supplied credentials that need testing.
Public eventBeforeRequestReceived
Raised on a background thread when the web server receives a request from a browser. Called before RequestReceived is raised.
Public eventExceptionCaught
Raised when an exception is caught on the background thread. The background thread should not pass ThreadAbortException through this.
(Inherited from IBackgroundThreadExceptionCatcher.)
Public eventExternalAddressChanged
Raised when the ExternalAddress property changes.
Public eventOnlineChanged
Raised when the Online property changes state.
Public eventRequestFinished
Raised after a response has been sent and the request completely closed down. The parameter is the UniqueId of the ResponseSentEventArgs original created for the request.
Public eventRequestReceived
Raised on a background thread when the web server receives a request from a browser.
Public eventResponseSent
Raised on a background thread when the web server responds to a request.
Top
Remarks

Once the properties have been set the server is controlled through the Online property. Setting it to true starts the server, setting it to false takes it offline.

When a request is received from a browser the RequestReceived event is raised. This is passed a RequestReceivedEventArgs object. If the handler(s) do not set the Handled property of the args then the server responds with a "Content not found" error, otherwise the content as described by Response property is sent to the browser.

The web server supports authentication. When authentication is required the AuthenticationScheme property should be set to a value that is not Anonymous. The server will raise AuthenticationRequired and pass an AuthenticationRequiredEventArgs. Setting the IsAuthenticated property will allow the request to proceed. The CacheCredentials property can be used to prevent the event being raised for credentials that the server has previously seen, and which were previously confirmed to be good by an event handler.

If the implementation of IWebServer is using the .NET Framework HttpListener then be aware that this will not run without admin privileges under Windows 7 or Vista, unless you first run a NETSH command to give the application permission to listen to a particular root and port. The installer for Virtual Radar Server sets this permission up so that Virtual Radar Server can remain at normal user permissions, if you use the server for your own applications you may need to do the same or ask the user to run your application as an administrator. It is not guaranteed, however, that the implementation is using HttpListener.

See Also