Cambia Research - Supporting the Microsoft .NET Developer Community Supporting the Microsoft .NET Developer Community  

     | Home  | Articles  | Categories  | Coders  | Search  | Submit  | Contact Us    
Microsoft's only factory asset is the human imagination. --Bill Gates

Share Your Knowledge! -- Create and submit your articles the easy way with WebWriter.

Updated:09:50 PM CT Feb 13, 2007
Posted:09:48 PM CT Feb 13, 2007

How do I get the application path in an ASP.NET application?

And convert it from a virtual path to a physical path

Author: Steve Lautenschlager

SnippetConversions.NET 1.1ASP.NET

 Summary

How do I get the application path in an ASP.NET application?

Retrieve the application path

string appPath = HttpContext.Current.Request.ApplicationPath;

This property returns the virtual application path.

An empty string indicates that the application is at the root of the website.

Other examples might be:

/c4
/myapplication
/myapps/AppNumberOne

Convert virtual application path to a physical path

string physicalPath = HttpContext.Current.Request.MapPath(appPath);


 Examples:

C:\inetpub\wwwroot\myweb\c4
C:\inetpub\wwwroot\myweb\myapplication
C:\inetpub\wwwroot\myweb\myapps/AppNumberOne

Add New Comment
CR Comments by Cambia Research
advertisement
 
Steve Lautenschlager (steve)
Steve is the founder and creator of Cambia Research. Developing and maintaining the site combines his passions for technology, writing and education.
Steve holds a Ph.D. in particle physics from Duke University, has worked at CERN, the European center for particle physics (where the web was born) and in Microsoft's web division with microsoft.com, msnbc.com and other web properties. Steve is a web consultant specializing in Microsoft.NET technologies. Read more here.


 
Copyright © Cambia Research 2002-2007. All Rights Reserved. steve [ at ] cambiaresearch.com