SventoryMang
SventoryMang

Reputation: 10479

Application Root in MVC App?

I am having some problems with an MVC app that uses logic based off data driven URLs (for routing) if my application is deployed to anywhere else other than the domain root.

I tried using various Request.Url properties to no avail.

Let's say I deploy my app to www.mydomain.com/myapp/ or even www.mydomain.com/myapp/subapp/. In these cases how can I get /myapp/ and /myapp/subapp/ respectively. Even if the user is on a totally different page such as /myapp/Users/Recent/?

I need that so I can prefix all the data driven URLs so my app still works when not on the domain root.

Thanks.

Upvotes: 4

Views: 4290

Answers (1)

SLaks
SLaks

Reputation: 887459

You're looking for HttpRuntime.AppDomainAppVirtualPath.

Note that all of the Url.* helpers will do this for you.

Upvotes: 10

Related Questions