【記錄】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 版本不一致所引起的,至於具體原因,尚不得知!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM