Monday 15 April 2013

asp.net mvc - Getting app root in MVC controller constructor -


I have to capture the physical path in the App Route in the MVC project; I use it to do with a repository which keeps its items on the file system.

Alternatively, I can use dependency injection, but I have the same problem; I do not have any requested until someone makes a call, so I can not use the request. Physical application paths .

You can do this in the controller:

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

No comments:

Post a Comment