相关疑难解决方法(0)

使用FormsAuthentication.SetAuthCookie存储更多信息

我使用aspx和c#来设置登录的身份验证cookie.

FormsAuthentication.SetAuthCookie(UserName, True)
Run Code Online (Sandbox Code Playgroud)

我想在同一个cookie中存储更多信息.我可以为此身份验证Cookie添加值,还是必须使用第二个http cookie?

基本上我正在寻找存储用户的Id所以我可以使用users表行键访问数据库

谢谢,伊甸园

c# asp.net asp.net-mvc forms-authentication

43
推荐指数
2
解决办法
6万
查看次数

FormsAuthenticationTicket.expiration v web.config值超时

这是一个MVC2网站,我遇到了FormsAuthentication票证的问题.30分钟后用户超时无法重新登录.在测试期间,DateTime.Now.AddMinutes(30)值设定为5000,一切正常,但是现在改为30,这是再当问题开始

从cookie创建

 FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
            1,
            user.UserID,
            DateTime.Now,
            DateTime.Now.AddMinutes(30),
            false,
            "user,user1",
            FormsAuthentication.FormsCookiePath);
Run Code Online (Sandbox Code Playgroud)

Web.config文件

<authentication mode="Forms">
  <forms loginUrl="~/Account.mvc/LogOn" timeout="2880" name=".ASPXFORMSAUTH" />
</authentication>
Run Code Online (Sandbox Code Playgroud)

票证创建中的到期值是否必须> = web.config值?

c# cookies formsauthentication formsauthenticationticket asp.net-mvc-2

13
推荐指数
1
解决办法
9492
查看次数