gpt4 book ai didi

forms-authentication - (Request.IsAuthenticated) 在使用 FormsAuthentication.SetAuthCookie(username,false) 后为假

转载 作者:行者123 更新时间:2023-12-03 18:17:51 24 4
gpt4 key购买 nike

我正在使用 VS2013 RC 和 MVC 5 构建一个网站,并且正在尝试使用 formsAuthentification 而没有在我的网站上注册永久用户。

我发布到我公司的 api 以验证用户名和密码。当这成功返回时,我想发出一个授权cookie:

System.Web.Security.FormsAuthentication.SetAuthCookie(username, false);

我在调用后看到 .ASPXAUTH=... cookie。

但是,我无法进入模板的 _LoginPartial.cshtml 页面上的 @if(User.Identity.IsAuthenticated) 或 @if(Request.IsAuthenticated) 块。

这种技术在 MVC 4 中确实对我有用,我正在尝试修改它以适应 MVC 5 的 OWIN 身份验证。

最佳答案

我需要在 web.config 中启用表单例份验证

<system.web>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
...
</system.web>

关于forms-authentication - (Request.IsAuthenticated) 在使用 FormsAuthentication.SetAuthCookie(username,false) 后为假,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19280829/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com