views:

27

answers:

1

How can I redirect user based on host in aspx page? For example, I want redirect user to localhost99.com if url is host22.com and redirect to host22.com if url is localhost99.com

I tried out something like this:

        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/");
        }
    }

Please help. Thanks.

+1  A: 

You would probably have better success doing this upstream in the request handling pipeline. Check out the possibility of inserting an http handler module in your application.

No Refunds No Returns