首页 > 解决方案 > ASP.NET 4.7 表单身份验证失败,提供的票证无效

问题描述

我们正在尝试从 TLS 1.0/1.1 更改为 1.2。唯一运行的协议是 1.2,.net 和 sql 已更改为支持 1.2。它在尝试登录时立即开始给我们这个错误。

事件代码:4005 事件消息:请求的表单身份验证失败。原因:提供的票证无效。事件时间:2018 年 6 月 1 日上午 9:27:58 事件时间 (UTC):2018 年 6 月 1 日下午 1:27:58 事件 ID:ed7b05ef18c84be1b02ae683df1b6e79 事件顺序:2 事件发生:1 事件详细代码:50201

这是在我的 web.config

    <authentication mode="Forms">
      <forms loginUrl="~/Login/MainLoginPage.aspx" defaultUrl="/default.aspx" name="LoginAuthCookie" timeout="525600" />
    </authentication>
  <location path="Mobile/Customers/CustomerList.aspx">
    <system.web>
      <httpRuntime requestValidationMode="2.0" />
    </system.web>
  </location>
  <location path="Mobile/Customers/JDE/NoCust.aspx">
    <system.web>
      <httpRuntime requestValidationMode="2.0" />
    </system.web>
  </location>
  <location path="login/mainloginpage.aspx">
    <system.web>
      <!--<pages validateRequest="false" />-->
      <httpRuntime requestValidationMode="2.0" />
    </system.web>
  </location>
  <location path="Applications">
    <system.web>
      <httpRuntime requestValidationMode="2.0" />
    </system.web>
  </location>

我们的测试页面仍然有效,但我们的生产却没有,它们具有相同的 web.config 页面。

我的问题是有谁知道为什么会发生这种情况以及如何解决它?我已经阅读了该网站上的一些主题,但它们没有任何帮助。如果您需要更多信息,请告诉我,并提前感谢您的回复。

标签: asp.netvb.net

解决方案


您可以添加ServicePointManager.SecurityProtocol = (SecurityProtocolType) 3072;到 Global.asax.cs。

public class Global : System.Web.HttpApplication
{
    protected void Application_Start(object sender, EventArgs e)
    {
        ServicePointManager.SecurityProtocol = (SecurityProtocolType) 3072;
    }
}

推荐阅读