
Redirecting Programmatically Using the Browser
You can redirect users to another page using the capabilities of the user's browser. In a browser redirect, the browser issues a new request to the target server in the form of an HTTP GET request.
You can trigger the redirect programmatically in client script or server code. In client script, you can call the form.submit method, provided the <form> element's method attribute value is get. In that case, if the current page contains form data, it is passed to the target server by appending it as a query string onto the requested URL.
In server code, you can programmatically redirect by calling the Redirect method. The method sends a command to the user's browser that causes the browser to issue an HTTP GET command for the target page. Calling the server Redirect method is the programmatic equivalent of clicking a hyperlink, in that it results in a new request for the target page. Because you are calling the methods from your own code, you can dynamically define the target URL, including any query-string information. If the source and target pages are in the same Web application, you can share data between the source and target pages by adding server code to store the data in session state.
Note: |
|---|
Internet Explorer through version 6.0 can process only up to 2,048 characters in the URL, including data in the query string. If the URL exceeds 2,048 characters, an error may result, or data in the query string might be truncated or not sent with the request. In ASP.NET Web pages, a GET request that includes post data can easily exceed 2,048 characters if view state information (which is stored in a hidden field) is part of the request, resulting in errors. Other browsers may not have this limitation. For more information, see article 208427, "Maximum URL Length Is 2,083 Characters in Internet Explorer" in the Microsoft Knowledge Base at http://support.microsoft.com. To work around this limitation when you are trying to share information among pages, you can redirect users by using HTTP POST requests as discussed in this topic. If your application requires an HTTP GET request, you can store information in an alternative way, without using a query string, such as in session state.
|