我正在尝试使用ASP.NET变量在我的Request.ServerVariables(“LOGON_USER”)页面中获得经过身份验证的用户名。它给了我一根空绳子。关于这个变量有很多主题。共同点使用的身份验证类型不是“无”,而是拒绝匿名访问。所以我在我的web.config中添加了这些行
<authentication mode="Forms"/>
<authorization>
<deny users = "?" /> <!-- This denies access to the Anonymous user -->
<allow users ="*" /> <!-- This allows access to all users -->
</authorization>我还是有一根空绳子。我怎样才能得到用户名?
也曾尝试过:
Request.ServerVariables["REMOTE_USER"];
Request.ServerVariables["UNMAPPED_REMOTE_USER"];
Request.ServerVariables["AUTH_USER"];
HttpContext.Current.User.Identity.Name;发布于 2014-11-24 22:16:36
终于修好了。如果要使用,则应在IIS中禁用匿名访问。
PS:禁用匿名访问会产生一些副作用,如无限登录重定向循环
https://stackoverflow.com/questions/26912109
复制相似问题