ReturnURL clearing querystring
Is it possible clear ReturnUrl from the server? I have a log开发者_StackOverflow社区in page where the user logouts and I want to direct them to a specific page but when ReturnURL is set it overrides my redirect page.
Update:
Ideally, I will only redirect a user who has just logged out versus someone who has bookmarked OR I will redirect regardless in special cases.
So these are the cases:
- A link or bookmark -> should redirect to specified page in most cases
- A logout that has a returnurl -> should NOT redirect to the page
- A special case -> should always redirect to my special case, i.e when a user needs to see something important
Is there a way to remove the returnurl from the logout/login status control?
You'll have to tweak the logon logic a bit. I stole my answer from http://digitalcolony.com/2007/05/override-returnurl-in-asp-net-security/.
Override the logon logic and do:
if (FormsAuthentication.Authenticate(txtName.Text, txtPassword.Text))
{
FormsAuthentication.SetAuthCookie(txtName.Text, true);
Response.Redirect("MySecuredStartPage.aspx", true);
}
Here is my tentative solution:
- I can change the LoginStatus control to redirect to the login.
- For normal cases I can allow the page to redirect, i.e bookmarks, etc.
- For special case I can Response.Redirect
Here is what helped me:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (!string.IsNullOrEmpty(Request.QueryString["ReturnUrl"])) //check if ReturnUrl is not empty
Response.Redirect("index.aspx"); //redirecting to the page I need
}
}
精彩评论