Fixing Unvalidated Redirects and Forwards in ASP.NET
Note: This post is part of our series on “How to Fix Unvalidated Redirects and Forwards“. The series contains examples on how to fix unvalidated redirects and forwards in various programming languages.
The following code will allow you prevent unvalidated redirects and Fowards in ASP.NET
<%@ Page Language="C#" %> <script runat="server"> private void Page_Load(object sender, EventArgs e) { // Check whether the browser remains // connected to the server. if (Response.IsClientConnected) { // If still connected, redirect // to another page. Response.Redirect("Page2CS.aspx", false); } else { // If the browser is not connected // stop all response processing. Response.End(); } } </script> <html> <head> </head> <body> <form runat="server"> </form> </body> </html>
One thought on “Fixing Unvalidated Redirects and Forwards in ASP.NET”