Username in asp.net

I tried the following methods:

Request.ServerVariables["LOGON_USER"]

or

HttpContext.Current.User.Identity.Name 

or

User.Identity.Name

- If I launched it using F5 from VS2010, it works fine.

- If I ran it in IIS (I tried it on 5.1 and 6.0, other IIS that I cannot use), there are empty lines.

In web.config, I have:

<authentication mode="Windows"/>
<authorization>
  <allow users="*"/>
</authorization>

Therefore, all users must be authenticated.

Perhaps there should be more things in web.config.

I tried it in IE, Firefox and Chrome.

I post this question before, but there was some misleading information, so I submit it again.

+3
source share
2 answers

Therefore, all users must be authenticated.

That's right. All users include anonymous.

0
source

- , , . :

<authentication mode="Windows" />
<authorization>
  <deny users="?" />
  <allow users="*" />
</authorization>

, - , .

? , * - ( ), - allow, .

, - ASP.NET MVC 3, , : , , , :

  <appSettings>
    <add key="autoFormsAuthentication" value="false" />
  </appSettings>  

, Windows - MVC 3 - , , , , , , , , - URL- ( ).

0

All Articles