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
You can use the HttpUtility.ParseQueryString to remove that element. If you use VB.NET then this code does this
Dim nvcQuery As NameValueCollection
Dim strQuery As String = ""
If Not IsNothing(Request.QueryString("ReturnUrl")) Then
If Request.QueryString("ReturnUrl").Length Then
nvcQuery = HttpUtility.ParseQueryString(Request.QueryString.ToString)
For Each strKey As String In nvcQuery.AllKeys
If strKey <> "ReturnUrl" Then
If strQuery.Length Then strQuery += "&"
strQuery += strKey + "=" + nvcQuery(strKey)
End If
Next
If strQuery.Length Then strQuery = "?" + strQuery
If Request.CurrentExecutionFilePath <> "/default.aspx" Then
Response.Redirect(Request.CurrentExecutionFilePath + strQuery)
Else
Response.Redirect("/" + strQuery)
End If
Response.Write(Server.HtmlEncode(strQuery))
End If
End If
I would put this in the Page.Init event - obviously you will need to change the "/default.aspx" to match the URL of your login page.