tags:

views:

38

answers:

1

I need to grab the physical path to the app root in an MVC project; I use this to serve from a repository that places its items on the file system.

Alternative, I could use Dependency Injection, but I'd have the same problem; I don't have a Request until someone calls an action, so I can't use Request.PhysicalApplicationPath.

A: 

You can do this in a controller:

var root = Server.MapPath(Url.Content("~/"));
Craig Stuntz