3

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.

Ruben Bartelink
  • 57,716
  • 25
  • 179
  • 233
mjibson
  • 16,762
  • 8
  • 29
  • 41

2 Answers2

4

Using AppDomain.CurrentDomain.BaseDirectory returns the correct directory.

mjibson
  • 16,762
  • 8
  • 29
  • 41
1

You might look at these two questions:

Community
  • 1
  • 1
Nicholas Carey
  • 65,549
  • 13
  • 92
  • 133