关于<authentication mode="Forms" />

System.Security 无法将类型为“System.Security.Principal.WindowsIdentity”的对象强制转换为类型“System.Web.Security.FormsIdentity”。

今天在编写代码是:无法将类型为“System.Security.Principal.WindowsIdentity”的对象强制转换为类型“System.Web.Security.FormsIdentity”。

解决办法如下:

 <authentication mode="Windows"/> 
  <!--
            如果在执行请求的过程中出现未处理的错误,
            则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
            开发人员通过该节可以配置
            要显示的 html 错误页
            以代替错误堆栈跟踪。

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->

注意红色字体:

改为: <authentication mode="Forms"/>

原文地址:https://www.cnblogs.com/mhker/p/3096930.html