开发者

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:

  1. A link or bookmark -> should redirect to specified page in most cases
  2. A logout that has a returnurl -> should NOT redirect to the page
  3. 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:

  1. I can change the LoginStatus control to redirect to the login.
  2. For normal cases I can allow the page to redirect, i.e bookmarks, etc.
  3. 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
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜