【发布时间】: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