How to Redirect User to Another Page or Website

Waqas Anwar
08 June 2009
6567 Views

If you want to redirect user to a different page or website from your code behind file, You can use Response.Redirect method which simply sends a message down to the browser, telling it to move to another page.

Response.Redirect("WebForm2.aspx");or
Response.Redirect("http://www.yahoo.com");
You can also use Server.Transfer to conserves server resources because it simply changes the "focus" on the Web server and transfers the request to another page without telling anything to the browser. This means you don't get quite as many HTTP requests coming through, which therefore eases the pressure on your Web server and makes your applications run faster.

Server.Transfer("WebForm2.aspx");
Keep in mind that there are few drawbacks when you are using this technique. First, this method only works with your own website pages, and you cannot redirect user to external website such as www.yahoo.com. Second, this technique doesn’t change the browser URL which can confuse users or can cause problems if user bookmark your page.