ASP.NET MVC 4/5 Authentication 身份验证无效

本文介绍了一个ASP.NET MVC 4/5应用程序在发布过程中遇到的身份验证问题,即无法与其他二级域名共享身份验证状态。通过调整HttpRuntime节点设置解决了此问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在 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 版本不一致所引起的,至于具体原因,尚不得知!



本文转自田园里的蟋蟀博客园博客,原文链接:http://www.cnblogs.com/xishuai/p/httpruntime-targetFramework-authentication-failed.html,如需转载请自行联系原作者

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值