Reputation: 71206
I need to get the absolute path of the root in an asp.net mvc view
I guess one way would be to do Url.Action("Index","Home")
and will get
http://localhost/myapp
anybody knows the right way ?
Upvotes: 2
Views: 110
Reputation: 12093
Url.Content()
will give you that. It's intended to allow you to get the path for static files, such as
<img src='<%: Url.Content("~/images/logo.gif") %>' />
Calling Url.Content("~")
will return /myapp/
, or just /
if your application isn't in a virtual directory.
Upvotes: 3
Reputation: 29427
I think you can use
string urlBase = Request.Url.GetLeftPart( UriPartial.Authority ) + Request.ApplicationPath;
Upvotes: 0