简体   繁体   中英

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.

You're looking for HttpRuntime.AppDomainAppVirtualPath .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM