.net - My.User.Name 与 My.User.CurrentPrincipal.Identity.Name

标签 .net vb.net

我发现 My.User.Name 和 My.User.CurrentPrincipal.Identity.Name 都返回登录到 PC 的用户的 Windows 登录 ID。然而,两者之间有区别吗?是否会出现它们不会返回相同值的情况?

最佳答案

My.User MSDN 页面上的信息对这些值以及它们何时存在差异进行了最佳总结

总而言之。最大的区别发生在 Windows 和 Web 应用程序之间。

For Windows applications, this property provides the same functionality as the CurrentPrincipal property. For Web applications, this property provides the same functionality as the User property of the object returned by the Current property.

关于.net - My.User.Name 与 My.User.CurrentPrincipal.Identity.Name,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3668554/

相关文章:

vb.net - 要包含在安装项目中的 "Release"文件 (Visual Studio)

windows - TaskDialog 显示中文文本而不是 en-us

vb.net - 你如何在 VB .NET 中将 Double 向下舍入到最接近的整数?

c# - 将遗留代码库从 VB 转换为 C# 是否有任何值(value)?

.net - 以编程方式续订 Windows 8 开发人员许可证?

c# - 使用基本字符串操作的字符串模式匹配

.net - 使用 LINQ 处理 Elasticsearch 结果

c# - 旧的 App_Web.xxxx.dll 会影响站点行为吗?

vb.net - 为 VB.NET 项目设置项目默认值,以便控件的默认修饰符属性为 Private

.net - 即使 EF 可以成功连接,Asp.Net Identity 也无法连接到数据库