There are only two industries that refer to their customers as "users". --Edward Tufte

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

And convert it from a virtual path to a physical path

By steve on Tuesday, February 13, 2007.
Updated Saturday, January 12, 2013.
Viewed 161,545 times. (8 times today.)
DeveloperTips and TutorialsASP.NETWeb

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

Back to Top

Share This Page:


Subscribe for free and read it when and where you want!

Get the latest tips and tools in your Inbox.

Your email address will NEVER be shared and you can unsubscribed at any time using the link at the bottom of every email.

Click Here to Subscribe

(Was this post helpful? If not, please leave a comment and let me know what you would like to hear about.)


 
comments powered by Disqus
Follow:
Share This Page:


Get the latest tips and tools in your Inbox. It's 100% free.



Click Here to Subscribe
Welcome!
Welcome to my blog about software development and the Microsoft stack.

I've been a full time .NET developer for fifteen years, but I didn't start my professional life as a programmer ... more