Fork me on GitHub

【记录】ASP.NET MVC 4/5 Authentication 身份验证无效

在 ASP.NET MVC 4/5 应用程序发布的时候,遇到一个问题,在本应用程序中进行身份验证是可以,但不能和其他“二级域名”共享,在其他应用程序身份验证,不能和本应用程序共享,示例代码:

System.Web.Security.FormsAuthentication.SetAuthCookie("蟋蟀", true);

webconfig 配置如下:

<system.web>
    <pages validateRequest="false"></pages>
    <authentication mode="Forms">
        <forms name=".DottextCookie" domain=".test.com" loginUrl="~/Account/Login" protection="All" />
    </authentication>
    <compilation debug="true" targetFramework="4.5.1" />
    <httpRuntime targetFramework="4.5.1" requestValidationMode="2.0" />
  </system.web>

比较“奇葩”的解决方式是:把 httpRuntime 节点中的“targetFramework="4.5.1"”去掉就好了,HttpRuntime.TargetFramework 属性参考:system.web.httpruntime.targetframework,感觉应该是应用程序的 Framework 版本和服务器 Framework 版本不一致所引起的,至于具体原因,尚不得知!

posted @   田园里的蟋蟀  阅读(2027)  评论(3编辑  收藏  举报
编辑推荐:
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2013-11-07 C算法编程题(六)串的处理
点击右上角即可分享
微信分享提示