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
  • 59,778
  • 26
  • 187
  • 249
mjibson
  • 16,852
  • 8
  • 31
  • 42

2 Answers2

4

Using AppDomain.CurrentDomain.BaseDirectory returns the correct directory.

mjibson
  • 16,852
  • 8
  • 31
  • 42
1

You might look at these two questions:

Community
  • 1
  • 1
Nicholas Carey
  • 71,308
  • 16
  • 93
  • 135