开发者

Getting app root in MVC controller constructor

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 u开发者_如何学Cse Request.PhysicalApplicationPath.


You can do this in a controller:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜