【发布时间】:2016-12-20 00:29:15
【问题描述】:
我在 .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();
//}
}
在此之后,我的应用会显示错误消息 HTTP Error 401.0 - Unauthorized
HTTP Error 401.0 - Unauthorized - image here
这是我的网络配置的一部分
<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 中有一些绑定和端点。
问候!!
【问题讨论】:
-
此 IIS 站点是否配置为 ASP.NET 应用程序?如果不是,这可能只是 IIS 错误,而不是 ASP.NET。
-
我在 IIS Express 中运行应用程序,没有部署。但我对 IIS 配置没有足够的了解。我回答你的问题了吗??
标签: c# asp.net xml asp.net-mvc visual-studio