asp.netninjectbootstrappingwebactivator

How do I get the website root outside of a request?


Inside of a request, I can use Server.MapPath() to access the website root. How can I access that function or otherwise get the website root without access to Server? I am trying to build a binding for ninject inside of WebActivator.PreApplicationStartMethod.

We have tried using Directory.GetCurrentWorkingDirectory(), which returned something in Microsoft Shared\Dev Server. However, in Global.asax.cs, calling Server.MapPath("") in Application_Start yields the directory I would like.


Solution

  • Using AppDomain.CurrentDomain.BaseDirectory returns the correct directory.