aspx page to redirect to a new page

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); %>

<%@ 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.


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

<%@ Page Language="C#" %>
<script runat="server">
  protected override void OnLoad(EventArgs e)

Method 2

You could also do this is plain in html with a meta tag:

  <meta http-equiv="refresh" content="0;url=new.aspx" />

Method 3

Darin’s answer works great. It creates a 302 redirect. Here’s the code modified so that it creates a permanent 301 redirect:

<%@ Page Language="C#" %>
<script runat="server">
  protected override void OnLoad(EventArgs e)

Method 4

If you are using VB, you need to drop the semicolon:

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

Method 5

Or you can use javascript to redirect to another page:

<script type="text/javascript">
    function toRedirect() {
        window.location.href="new.aspx" rel="nofollow noreferrer noopener";

Call this toRedirect() function from client (for ex: onload event of body tag) or from server using:

Method 6

Even if you don’t control the server, you can still see the error messages by adding the following line to the Web.config file in your project (bewlow <system.web>):

<customErrors mode="off" />

Method 7

Redirect aspx :


    <script runat="server">
    private void Page_Load(object sender, System.EventArgs e)
    Response.Status = "301 Moved Permanently";


Method 8

In a special case within ASP.NET If you want to know if the page is redirected by a specified .aspx page and not another one, just put the information in a session name and take necessary action in the receiving Page_Load Event.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x