Dav*_*per 5 c# xml asp.net asp.net-mvc visual-studio
我在 .NET MVC 应用程序中有一个新的遗留代码。
第一次运行它时,提示 Windows 身份验证警报让我登录。我已经在 web.config 中禁用了它。
然后很明显看到验证码,但我已经评论它跳转了。
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
//if (!Request.IsAuthenticated) return;
//var userPrincipal = new CompanyPrincipal((WindowsIdentity) HttpContext.Current.User.Identity);
//var userPrincipal = new CompanyPrincipal(WindowsIdentity.GetCurrent());
//if (userPrincipal.IsAuthenticated)
//{
//HttpContext.Current.User = userPrincipal;
WindowsPrincipal fakeUser = new WindowsPrincipal(WindowsIdentity.GetCurrent());
HttpContext.Current.User = fakeUser;
//}
//else
//{
// Response.StatusCode = 401;
// Response.StatusDescription = "Unauthorized";
// Response.SuppressContent = true;
// HttpContext.Current.ApplicationInstance.CompleteRequest();
//}
}
Run Code Online (Sandbox Code Playgroud)
在此之后,我的应用程序显示错误消息HTTP 错误 401.0 - 未经授权
这是我的网络配置的一部分
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<remove name="UrlRoutingModule-4.0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
和这部分
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<globalization culture="es-MX" uiCulture="es-MX" />
<!--<authentication mode="Windows" />-->
<authentication mode="None"/>
<authorization>
<allow users="*" />
<!--<deny users="*" />-->
</authorization>
</system.web>
Run Code Online (Sandbox Code Playgroud)
我错过了什么?我已经授予应用程序文件夹权限,但我认为还有更多权限。
有什么建议吗??我在 web.config 中有一些绑定和端点。
问候!!
| 归档时间: |
|
| 查看次数: |
13503 次 |
| 最近记录: |