如何允许匿名与windowsAuthenticated一起访问WebApplication

时间:2017-09-05 04:13:15

标签: c# .net authentication intranet

是否可以允许 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=trueanonymousAuthentication enabled=true。 WebApplication不是MVC或类似的东西 - 平原.aspx。

目前有匿名访问权限,但对于 windowsAuthenticated 用户,HttpContext.Current.User.Identity.Name并不总是包含用户名。有时我需要在浏览器中多次按F5才能填充HttpContext.Current.User.Identity.Name

0 个答案:

没有答案