Posts Tagged ‘Response’

How to Redirect Users to a Different Page in C#

Redirecting a web user to another web page without requiring the user to click a link is a common practice in web development. The built in function of C# is the Redirect function. The redirection function can take one or two input parameters. With one input parameter, simply specify the redirect url.

Response.Redirect("http://www.victorchen.info");

By using only one parameter, code after the Redirect function can still be executed. To prevent this, use the overloaded Redirect function with two input parameters. The first input parameter is still the redirect url, but the second input is the a boolean variable indicating whether remaining code on the page should continue executing or stop when the redirection function is reached.

Response.Redirect("http://www.victorchen.info", false);

Redirect is a function of the HttpResponse class. The Redirect function returns void.