C# 如何修复:您没有查看此目录或页面的权限?
我在.NETMVC应用程序中有一个新的遗留代码 第一次运行时,提示windows身份验证警报让我登录。我已经在web.config中禁用了它 很明显,我看到了一个身份验证代码,但我已经将其注释为跳转C# 如何修复:您没有查看此目录或页面的权限?,c#,asp.net,xml,asp.net-mvc,visual-studio,C#,Asp.net,Xml,Asp.net Mvc,Visual Studio,我在.NETMVC应用程序中有一个新的遗留代码 第一次运行时,提示windows身份验证警报让我登录。我已经在web.config中禁用了它 很明显,我看到了一个身份验证代码,但我已经将其注释为跳转 protected void Application_AuthenticateRequest(object sender, EventArgs e) { //if (!Request.IsAuthenticated) return; //var userPr
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();
//}
}
在此之后,我的应用程序将显示错误消息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>
这部分呢
<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>
我错过了什么??我已经给了应用程序文件夹许可证,但我认为还有更多的东西
有什么建议吗??我在web.config中有一些绑定和端点
问候 由于您使用的是windows主体,也许您应该将身份验证模式更改为“windows”。此IIS站点是否配置为ASP.NET应用程序?如果不是,这可能只是一个IIS错误,而不是ASP.NET。我正在IIS Express中运行应用程序,没有部署。但是我对IIS配置没有足够的了解。我回答你的问题了吗?但是如果我想跳过身份验证,我该怎么做??