简体   繁体   English

应用程序根目录在MVC App中?

[英]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. 我的MVC应用程序存在一些问题,如果我的应用程序部署到域根以外的任何其他地方,则使用基于逻辑的数据驱动URL(用于路由)。

I tried using various Request.Url properties to no avail. 我尝试使用各种Request.Url属性无济于事。

Let's say I deploy my app to www.mydomain.com/myapp/ or even www.mydomain.com/myapp/subapp/ . 假设我将我的应用程序部署到www.mydomain.com/myapp/ ,甚至是www.mydomain.com/myapp/subapp/ In these cases how can I get /myapp/ and /myapp/subapp/ respectively. 在这些情况下,我如何分别获得/myapp//myapp/subapp/ Even if the user is on a totally different page such as /myapp/Users/Recent/ ? 即使用户位于完全不同的页面上,例如/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. 我需要这样,所以我可以为所有数据驱动的URL添加前缀,这样我的应用程序在不在域根目录时仍可正常工作。

Thanks. 谢谢。

You're looking for HttpRuntime.AppDomainAppVirtualPath . 您正在寻找HttpRuntime.AppDomainAppVirtualPath

Note that all of the Url.* helpers will do this for you. 请注意,所有Url.*帮助程序都会为您执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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