aspx page to redirect to a new page

Stoob picture Stoob · Jul 7, 2009 · Viewed 244k times · Source

What is the code required to redirect the browser to a new page with an ASPX page?

I have tried this on my page default.aspx :

<% Response.Redirect("new.aspx", true); %>

or

<%@ Response.Redirect("new.aspx", true); %>

And these resulted in a server error that is undetermined. I cannot see the error code; because the server is not in my control and the errors are not public.

Please provide all necessary code from line 1 of the page to the end, and I would really appreciate it.

Answer

Darin Dimitrov picture Darin Dimitrov · Jul 7, 2009
<%@ Page Language="C#" %>
<script runat="server">
  protected override void OnLoad(EventArgs e)
  {
      Response.Redirect("new.aspx");
  }
</script>