I want to remove \"returnurl=/blabla\" from address bar when a user want to access to a login required page. Because I\'m trying to redirect the user to a static page after
If you want to remove returnURL from request and redirect to specific path, you can follow this steps.
Firstly get the current context, verify if the user is authenticated and finally redirect the current path.
HttpContext context = HttpContext.Current;
//verify if the user is not authenticated
if (!context.User.Identity.IsAuthenticated)
{
//verify if the URL contains ReturnUrl
if (context.Request.Url.ToString().Contains("ReturnUrl"))
{
//redirect the current path
HttpContext.Current.Response.Redirect("~/login.aspx");
}
}
I put this code into Page_Load method from my class Login.aspx.cs