问题描述
我们有一个ASP.NET内部网站,提供给谁不是在身体上并登录到本地计算机或别的谁通过VPN远程连接用户的用户。是否有办法来自动获取谁是基于用于任何登录到用于VPN?
We have an ASP.NET intranet site, available to users who are either physically at and logged into a local machine or else to users who connect remotely via VPN. Is there a way to automatically get the username of whoever is accessing the page based on the name used to either log into the local machine or that used for the VPN?
推荐答案
此,如果你在页面中使用Windows身份验证是可行的。
This is possible if you're using Windows Authentication in your pages.
您可以使用 Page.User.Identity.Name
或更完整的 System.Web.HttpContext.Current.User.Identity.Name
。
You can use either Page.User.Identity.Name
or the more complete System.Web.HttpContext.Current.User.Identity.Name
.
了解更多关于在这里:
Read more about it here:
Enabling内联网的ASP.NET Web应用程序内的Windows身份验证
Enabling Windows Authentication within an Intranet ASP.NET Web Application
如果你是,但是,使用窗体身份验证,你必须保持当前用户跟踪自己,其中最常用的方法将是在会话变量存储他们的登录名。
If you are, however, using Forms Authentication, you'll have to keep track of the current user yourself, the most common method of which will be by storing their login name in a Session variable.
这篇关于获取用户的本地网络中访问ASP.NET内部网页的用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!