【问题标题】:How to redirect in ASP.NET based on URL?如何在 ASP.NET 中基于 URL 进行重定向?
【发布时间】:2010-01-04 03:51:47
【问题描述】:

如何在 aspx 页面中根据主机重定向用户? 例如,如果 url 是 host22.com,我想将用户重定向到 localhost99.com,如果 url 是 localhost99.com,我想重定向到 host22.com

我试过这样的:

        protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.ServerVariables["SCRIPT_NAME"] + "?" + Request.ServerVariables["QUERY_STRING"] != "host22.com/default.aspx") 
        {
            Response.Redirect("http://localhost99.com/");
        }
    }

请帮忙。谢谢。

【问题讨论】:

    标签: c# asp.net iis-7 windows-server-2008


    【解决方案1】:

    在请求处理管道的上游执行此操作可能会更成功。查看在您的应用程序中插入 http 处理程序模块的可能性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-26
      • 2010-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-27
      • 1970-01-01
      • 2017-06-21
      相关资源
      最近更新 更多