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
Add this to your Global.asax file.
public class MvcApplication : HttpApplication {
private const String ReturnUrlRegexPattern = @"\?ReturnUrl=.*$";
public MvcApplication() {
PreSendRequestHeaders += MvcApplicationOnPreSendRequestHeaders;
}
private void MvcApplicationOnPreSendRequestHeaders( object sender, EventArgs e ) {
String redirectUrl = Response.RedirectLocation;
if ( String.IsNullOrEmpty(redirectUrl)
|| !Regex.IsMatch( redirectUrl, ReturnUrlRegexPattern ) ) {
return;
}
Response.RedirectLocation = Regex.Replace( redirectUrl,
ReturnUrlRegexPattern,
String.Empty );
}