asp.net mvc forms验证不通过的解决方法
因项目需要,使用MVC并使用forms登录验证,配置启用forms验证,但是登录后却无法访问授权的页面,找了很多资料都无法解决,最后看到webconfig文件中有一句 <remove name="FormsAuthentication" />
这句话删除了forms登录验证,难怪登录后却无法定向到首页,删除这句话即可。
<add key="owin:AutomaticAppStartup" value="false"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules>
<authentication mode="Forms">
<forms loginUrl="~/Login/Login" timeout="288000" />
</authentication>
</system.web>
<system.webServer>
<modules>
<remove name="FormsAuthentication" />
<remove name="ApplicationInsightsWebTracking" />
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>

浙公网安备 33010602011771号