当我的应用程序指向其他地方时,如何使用Url.Action和Html.ActionLink?

时间:2012-08-23 20:41:44

标签: c# asp.net-mvc

我在apps.server.com/appname上托管了一个C#MVC应用程序,但我在我公司的F5上进行了URL重写,使该应用程序对www.server.com/apps/appname可见。现在,当我导航到该URL时,没有任何图像或链接可用,因为在使用@ Url.Content(“〜/ URL”)时它们都指向www.server.com/appname。我需要为所有帮助程序类做什么才能知道我在别名URL下而不是它认为的位置(即apps.server.com URL)?

1 个答案:

答案 0 :(得分:1)

如果您在IIS 7 Integrated Pipeline模式下运行,请尝试在Global.asax中添加以下内容:

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