http redirect in csharp

Here is an example of how to perform a HTTP redirect in C# using ASP.NET:

main.cs
// Redirect to a new page
Response.Redirect("http://example.com/newpage.aspx");

// Redirect to a new page with a query string
Response.Redirect("http://example.com/newpage.aspx?id=123");

// Redirect to a local page
Response.Redirect("~/newpage.aspx");

// Redirect with a permanent HTTP redirect status code
Response.RedirectPermanent("http://example.com/newpage.aspx");

// Redirect with a temporary HTTP redirect status code
Response.RedirectTemporary("http://example.com/newpage.aspx");
492 chars
15 lines

Note that these redirects should generally be performed in the Page_Load or Page_Init events of your ASP.NET page.

gistlibby LogSnag