How to get application root directory (full physical path) in OnApplicationStarted in MVC3 application?

So far I have used:

Dim appPath = HttpContext.Current.Request.MapPath(HttpContext.Current.Request.ApplicationPath) 

But today I moved my application from IIS6 to IIS7, and I got the exception "Request is not available in this context." This is due to the integrated mode pipeline in IIS7. I don’t want to go into classic mode, so I'm looking for another way to get the path to the application (which is "C: \ SVN \ L2E \ trunk \ Website").

Does anyone have an idea how I can get the full physical path of my MVC3 application?

+9
path iis-7 asp.net-mvc-3 integrated-pipeline-mode
source share
3 answers

You can use System.Web.HttpRuntime.AppDomainAppVirtualPath to get the virtual path and call System.Web.Hosting.HostingEnvironment.MapPath to map the virtual path to the physical.

+16
source share

use this:

  AppDomain.CurrentDomain.BaseDirectory 
+13
source share

HttpRuntime.AppDomainAppPath from the System.Web .

0
source share

All Articles