How do I redirect to another page with ASP.NET? How do I redirect to another page with ASP.NET? asp.net asp.net

How do I redirect to another page with ASP.NET?


Not quite sure from your question whether you're after ASP VB or C#...so...

// C#

private void Button1_Click(object sender, System.EventArgs e){   Server.Transfer("Webform2.aspx");}

' Visual Basic

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click        Server.Transfer("Webform2.aspx")End Sub

For more information, I direct you to:

http://msdn.microsoft.com/en-us/library/540y83hx%28VS.71%29.aspx


Use one of these methods:

One-time redirect (HTTP 301)

Response.Redirect("page to redirect to");

Permanent redirect (HTTP 302), only available in ASP.NET 4.0

Response.RedirectPermanent("page to redirect to");