Support us .Net Basics C# SQL ASP.NET Aarvi MVC Slides C# Programs Subscribe Download

Response.Redirect in asp.net - Part 52

Suggested Videos
Part 49 - ValidationSummary
Part 50 - ValidationGroups
Part 51 - Different page navigation techniques

The following are the different page navigation techniques in asp.net

1. Hyperlink control - Discussed in Part 13 and Part 51 of the ASP.NET video series
2. Response.Redirect 
3. Server.Transfer 
4. Server.Execute
5. Cross-Page postback
6. Window.Open 



In this video, We will discuss about Response.Redirect. Response.Redirect is similar to clicking on a hyperlink. The Hyperlink control does not expose any server side events. So when the user clicks on a hyperlink, there is no server side event to intercept the click.

So, if you want to intercept a click event in code, use the Button, LinkButton or the ImageButton server control. In the button click event, call Response.Redirect() method. When the user clicks the button, the web server receives, a request for redirection. The server then sends a response header to the client. The client then automatically issues a new GET request to the web server. The web server will then serve the new page. So, in short, Response.Redirect causes 2 request/response cycles.
Response.Redirect in asp.net

Also, note that when Response.Redirect is used the URL in the address bar changes and the browser history is maintained.

Response.Redirect() can be used to navigate pages/websites on the same web server or on a different web server.



5 comments:

  1. Hi Venkat,

    what is the difference between Response.Redirect ("URL", true) and Response.Redirect ("URL", False).
    Also what is the concept behind Response.RedirectParmanent .

    Thanks in advance
    Rohan

    ReplyDelete
    Replies

    1. true - url replaces the current document in the history list.
      false - url creates a new entry in the history list.

      Delete
    2. response.redirect true means it doesn't execute the that is written after response.redirect like this
      response.redirect(somepage);
      int i=0;
      console.writeline(i.tostring());

      false is opposite to it

      Delete
  2. True - will terminate execution of current page
    false - will not terminate execution of current page

    ReplyDelete
  3. When I using response redirect my database does not get update or data does not get insert on database using Form-view insert command. How can I redirect to another page but make sure that before being redirect the data gets insert? thanks in advance!

    ReplyDelete

It would be great if you can help share these free resources