Get current logged in user IIS returning DefaultAppPool

我是研究僧i 提交于 2020-06-17 02:59:17

问题


I have an asp.net application on my server that uses WindowsAuthentication to log in. The scenario is simple: users logged in, will use the same credentials to login the application.

Certainly, on IISExpress on my machine works great, but when I try to login the application on server, the current user returned is DefaultAppPool.

I guess it's a missing impersonate config on IIS. I tried to get the current user with:

string username = HttpContext.Current.Request.LogonUserIdentity.Name;
string username = WindowsIdentity.GetCurrent().Name;

... and all of above returns the current user loggedin but only works on IISExpress, but not on server IIS.

IIS Express config
DefaultAppPool
- Framework Version 4.0
- Application Pool Identity

Application Authentication Config
Application Authentication Config

Server Info
Windows 2008 R2 Enterprise
IIS 7.5

PD: Is not my best English


回答1:


I had a similar issues; as far as I can tell it is because the web.config file needs to have the following entries:

<authentication mode="Windows" />
    <identity impersonate="true" />

Also in your IIS/Authentication section in Internet Information Services (IIS) Manager, make sure only Anonymous Authentication and Windows Authentication is Enabled. I had ASP.NET Impersonation checked by mistake and it was giving me the same error you described in this post. Once I disabled that (along with the other modifications), it seems to be working fine.



来源:https://stackoverflow.com/questions/29400373/get-current-logged-in-user-iis-returning-defaultapppool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!