0

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 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.