WebContext Class
Manages the path context for the current Web application. This class cannot be inherited.
Assembly: System.Web (in System.Web.dll)
| Name | Description | |
|---|---|---|
![]() | WebContext(WebApplicationLevel, String, String, String, String, String) | Initializes a new instance of the WebContext class. |
| Name | Description | |
|---|---|---|
![]() | ApplicationLevel | Gets a WebApplicationLevel object that represents the path level of the current Web application. |
![]() | ApplicationPath | Gets the application path of the current Web application. |
![]() | LocationSubPath | Gets the location subpath of the Web application. |
![]() | Path | Gets the current virtual path of the Web application. |
![]() | Site | Gets the name of the current Web application. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | ToString() | Returns a string that represents the application's configuration path.(Overrides Object.ToString().) |
The following example shows how to use the WebContext class.
Imports System Imports System.Configuration Imports System.Web Imports System.Web.Configuration Namespace Samples.Aspnet.SystemWebConfiguration Class UsingWebContext Public Shared Sub Main() Try ' Set the path of the config file. Dim configPath As String = "/aspnet" ' Get the Web application configuration object. Dim config As Configuration = _ WebConfigurationManager.OpenWebConfiguration(configPath) ' Get the context. Dim webContext As WebContext = config.EvaluationContext.HostingContext ' Display title and info. Console.WriteLine("ASP.NET WebContext Info") Console.WriteLine() ' WebContext - Application Level. Console.WriteLine("ApplicationLevel: {0}", _ webContext.ApplicationLevel.ToString()) ' WebContext - Application Path. Console.WriteLine("ApplicationPath: {0}", _ webContext.ApplicationPath.ToString()) ' WebContext - Path. Console.WriteLine("Path: {0}", webContext.Path.ToString()) ' WebContext - Site. Console.WriteLine("Site: {0}", webContext.Site.ToString()) Catch e As Exception ' Unknown error. Console.WriteLine(e.ToString()) End Try ' Display and wait Console.ReadLine() End Sub End Class End Namespace
Available since 2.0
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
.jpeg?cs-save-lang=1&cs-lang=vb)
.jpeg?cs-save-lang=1&cs-lang=vb)