简体   繁体   中英

IIS7 Windows authentication(how to retrieve username from domain?)

This is my code

    Dim username2 As System.Security.Principal.IPrincipal
    username2 = System.Web.HttpContext.Current.User
    Dim username As String
    username = username2.Identity.Name
    Response.Write(username)

I am using asp.net application in vs 2010 I need to use windows authentication in iis7 (user and domain). I have set up windows authentication in web.config and enabled windows authentication in iis. I disabled anonymous authentication. when I browse to localhost, it is asking for username and password. Any ideas?

Are you running this in firefox? i had the same problem when my default browser was set to firefox. It would ask me for credentials every time. If you use IE there should be no problem with this. Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM