Sending a visitor to another page
A redirect moves the visitor to a different page without them choosing it. It is common after a successful save or a failed sign in.
The usual call
C#
// send the visitor to the order list
Response.Redirect("orders.aspx");When to redirect
- After saving, so a refresh does not save the record twice.
- After signing in, to return the visitor to where they were going.
- When the visitor is not allowed to see the page they asked for.
Redirect, then stop. The redirect call does not end your code by itself. Anything after it still runs, so guard the rest of the method if it matters.
Passing a value along with the visitor is the job of session state.