c# - 拒绝访问 401.2 ASP.NET Web 表单
问题描述
我遇到了这个让我头疼的问题,我真的不知道为什么。
我只想创建一个带有登录页面的站点,如果用户没有登录并且试图查看另一个页面,它必须重定向到登录页面。
这是在 VS 2017 中运行的 .Net Framework 4.5 ASP Webforms
这是我的 web.config
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1" />
<pages>
<namespaces>
<add namespace="System.Web.Optimization" />
</namespaces>
<controls>
<add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
</controls>
</pages>
<authentication mode="Forms">
<forms name="validaciones" loginUrl="~/Login.aspx" protection="All" timeout="10" path="/"/>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
<customErrors mode="Off"></customErrors>
</system.web>
<location path="Login.aspx" >
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
<add name="Access-Control-Allow-Credentials" value="true" />
</customHeaders>
</httpProtocol>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
</configuration>
解决方案
推荐阅读
- c# - C# MVC - 将 ViewModel 对象从视图传递到控制器
- javascript - 决策树交互风格前端
- rx-java2 - rxjava2 与 Spring Boot 2
- nginx - Kubernetes Ingress Nginx 加载资源 404
- sql - 在 Rails 迁移中使用 SQL 访问 CarrierWave 图像 url
- firebase - 如何在 Firebase 数据库中查询嵌套属性?
- swift - iOS 11 MDM:托管应用配置不起作用
- zabbix - HAProxy 背后的 Zabbix Server
- java - JdbcPagingItemReader 混淆SQL语句
- ios - 如何从 tableView 重新加载表格?