如何使用Url.Action和Html.ActionLink指出别的地方我的应用程序时? [英] How can I use Url.Action and Html.ActionLink when my application is pointed somewhere else?

查看:134
本文介绍了如何使用Url.Action和Html.ActionLink指出别的地方我的应用程序时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有托管apps.server.com/appname一个C#MVC应用程序,但我有一个URL重写对我公司的F5,使该应用程序可见www.server.com/apps/appname~~V正在做。现在,当我浏览到该网址没有图像或环节的工作,因为它们都指向使用@ Url.Content(〜/ URL)时www.server.com/appname~~V。我需要什么我所有的助手类的做知道我下别名URL,而不是它认为这是(即apps.server.com URL)?

I have a C# MVC application hosted on apps.server.com/appname but I have a URL rewrite being done on my company's F5 that makes that application visible to www.server.com/apps/appname. Now when I navigate to that url no images or links work because they are all pointing to www.server.com/appname when using @Url.Content("~/URL"). What do I need to do for all of my helper classes to know that I am under an aliased URL instead of where it thinks it is (ie, the apps.server.com URL)?

推荐答案

如果您正在运行在IIS 7集成管道模式尝试将在下面的的Global.asax

If you are running in IIS 7 Integrated Pipeline mode try putting the following in your Global.asax:

protected void Application_BeginRequest(object sender, EventArgs e)
{
    Request.ServerVariables.Remove("IIS_WasUrlRewritten");
}

这篇关于如何使用Url.Action和Html.ActionLink指出别的地方我的应用程序时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆