asp.net – HttpContext.Current.User为空,即使Windows身份验证已打开

在Windows Server 2008中的IIS7中,我有一个虚拟目录,具有匿名访问权限和Windows身份验证.在我的web.config中,我有:
<authentication mode="Windows"/>
<authorization>
            <allow roles="MYGROUP"/>
            <deny users="*"/>
</authorization>

<system.webServer>
    <!-- IIS7 security settings -->
    <security>
        <authorization>
                <add accessType="Deny" users="*"/>
                <add accessType="Allow" roles="MYGROUP"/>
        </authorization>
    </security>
</system.webServer>

然而当我从IE访问default.aspx并在Global.asax.vb Application_AuthenticateRequest()中设置一个断点时,我得到一个null HttpContext.Current.User,我希望自己的身份.几乎就像匿名访问一样?

我可以如何解决这个问题?一切似乎都在IIS6中运行.

解决方法

将应用程序池移回古典的答案只是拖延问题.

而是将应用程序池单独放置,并将您的验证检查从Application_AuthenticateRequest()移动到管道中的下一个函数:

Application_AuthorizeRequest(object sender,EventArgs e)

到那时,集成的应用程序池已经完成了Windows身份验证,允许您不从HttpContext.Current.User接收null.

可以在标题Runtime Fidelity(向下))找到流水线here(由CarlosAg提供的链接).

管道的可视化可以在asp website message lifecycle page找到.在控制器部分检查两个绿色框“认证过滤器”和“授权过滤器”.这些是你正在搞乱的地方.

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....