是否可以允许 windowsAuthenticated 和匿名用户访问网络应用?因此,如果用户 windowsAuthenticated ,我将收到非空HttpContext.Current.User.Identity.Name
,但如果用户不允许 windowsAuthenticated (匿名)访问(空HttpContext.Current.User.Identity.Name
)。
我使用了这样的web.config system.web
部分:
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<authentication mode="Windows" />
<authorization>
<allow users="*,?"/>
</authorization>
</system.web>
服务器是windowsAuthentication enabled=true
和anonymousAuthentication enabled=true
。
WebApplication不是MVC或类似的东西 - 平原.aspx。
目前有匿名访问权限,但对于 windowsAuthenticated 用户,HttpContext.Current.User.Identity.Name
并不总是包含用户名。有时我需要在浏览器中多次按F5才能填充HttpContext.Current.User.Identity.Name
。