English 中文(简体)
如何正确签名用户
原标题:How to properly sign out user

我制作了一个 ASP.NET 的会员提供商,它运作良好,但我注意到,如果用户更改密码签名,然后试图再次签名,密码就失败了,如果用户有两个或两个以上的账户,用一个账户签名,并试图与另一个账户签名。如果用户清理浏览器中的饼干,他/她可以再次签名,那么当用户签名退出饼干时,似乎出于某种原因不会删除。这是我的签名代码:

void ClearAuthenticationCookie()
    {
        var cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, String.Empty) { Expires = DateTime.Now.AddYears(-1) };
        Response.Cookies.Add(cookie1);            
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        FormsAuthentication.SignOut();

        ClearAuthenticationCookie();

        FormsAuthentication.RedirectToLoginPage();
    }
最佳回答

现在我想通了,这是很傻的; 表格核准性。 从符号输出页面中重新直接到“ 下载”, 在 URL 中输入 / Login. aspx? ReturnUrl_ 2fAccount% 2fLogout. aspx, 所以如果您试图在它上签名, 重新将它重定向到符号输出页面。 我本该看到这一点的, 抱歉浪费您的时间 :

问题回答

尝试在您签名退出页面的页面负载中添加此选项 :

Session.Clear();




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签