MVC 站点与虚拟应用程序路由
我们使用 TFS 将应用程序部署到多个环境(Dev、QA、Prod)。很简单,我们的开发和 QA 环境具有诸如 dev.domain/APPLICATION 和 qa.domain/APPLICATION 之类的 URL。因此,我们有一个站点,每个应用程序都是一个虚拟应用程序。
然而在生产中,他们希望每个应用程序都有自己的站点,例如 APPLICATION.domain.com... Grrr!在 Visual Studio 中,应用程序的属性被配置为位于“虚拟路径”中。我不确定应该如何解决这个问题。该应用程序包含以下代码: < ;#= Name #>
这会导致生产出现问题,因为它不在虚拟应用程序中,
我可以创建一个名为 application.domain.com 的空目录,然后添加一个虚拟目录。应用程序,但我必须在站点的根目录中放置一个重定向才能转到虚拟应用程序,或者我可以以某种方式配置该应用程序?
We use TFS to deploy our applications to multiple environments (Dev, QA, Prod). Simple enough, our Dev and QA environments have URLS like dev.domain/APPLICATION and qa.domain/APPLICATION. So we have a single site with each application as a virtual application.
However in production, they want each application to be its own site, such as APPLICATION.domain.com... Grrr! In Visual Studio, the application's properties is configured to be in a "Virtual Path". I"m not sure how I should go about this issue. The appliation contains code such as: <a href='/APPLICATION/File/Download?id=<#= PkFileId #>'><#= Name #></a>
which causes problems in production since its not in a virtual application.
I could make a site called application.domain.com with an empty directory. Then add a Virtual Application, but then I would have to put a redirect in the root of the site to go to the virtual application. Or perhaps I can somehow configure the application? Not sure what my options are... Any suggestions are appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ASP.NET MVC 应用程序不应包含类似的代码(硬编码 url 的代码)。在 ASP.NET MVC 应用程序中,您应该始终使用 HTML 和 Url 帮助程序:
这样,无论您的路由如何配置或您的应用程序托管在哪个虚拟目录下,都可以确定它应该工作。
更新:
在您发表评论后,您似乎正在使用 Telerik Grid。在这种情况下,您可以尝试一些方法来生成正确的锚点:
ASP.NET MVC applications should not contain code like that (a code in which urls are hardcoded). In ASP.NET MVC applications you should always use HTML and Url helpers:
This way it is certain that no matter how your routes are configured or under which virtual directory your application is hosted, it should work.
UPDATE:
After your comment it looks like you are using the Telerik Grid. In this case you may try something along the lines to generate proper anchors: