I have created a sample html
page and hosted it on IIS
. I have enabled windows authentication
. Now what I want to do is whenever I run the application, the Login ID
entered by the user to be stored in database
(I have already created a web service
to send data to my database
). I just want know the command
to store the Login ID
in a variable. Kindly assist.
This should get you the username:
System.Web.HttpContext.Current.User.Identity.Name
Here is an explanation on how it works:
Try this
WindowsIdentity yourUserIdentity = HttpContext.Current.Request.LogonUserIdentity;
Now you can get the User name by the following property of the WindowsIdentity object yourUserIdentity.
yourUserIdentity.Name
如果您使用Windows身份验证,则可以使用它来获取LoginID
string user = Request.ServerVariables["LOGON_USER"];
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.