Export (0) Print
Expand All

HttpRequest::ApplicationPath Property

Gets the ASP.NET application's virtual application root path on the server.

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)

public:
property String^ ApplicationPath {
	String^ get ();
}

Property Value

Type: System::String
The virtual path of the current application.

Use this property to construct a URL relative to the application root from a page or Web user control that is not in the root directory. This allows pages and shared controls that exist at different levels of a directory structure to use the same code to link to resources at fixed locations in the application.

The following example uses the Write method to HTML-encode and then write the value of the ApplicationPath property to a text file. This code example is part of a larger example provided for the HttpRequest class. It assumes the existence of a StreamWriter object named sw.

No code example is currently available or this language may not be supported.

The following example uses the ApplicationPath property to programmatically construct a path to a resource that is in a fixed location in the application. The page that references the resource does not have to be located in the same directory as the resource.

No code example is currently available or this language may not be supported.

If you run this example in a Web application that is named WebSite1, /WebSite1 will be displayed as the value of the ApplicationPath property and /WebSite1/images/Image1.gif will be displayed as the complete path of the image.

.NET Framework

Supported in: 4.6, 4, 3.5, 3.0, 2.0, 1.1, 1.0

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.

Show:
© 2014 Microsoft