Page.User.Identity与Request.LogonUserIdentity之间的差异
Page.User.Identity和Request.LogonUserIdentity之间有什么区别(幕后)? 不是类型,名称等的差异,而是它们在幕后实现的差异(即一个调用windows xxx api,另一个调用asp.net xxx api …)。
这取决于您用于对用户进行身份validation的机制,以及您用于模拟的设置。
例如,在VS开发服务器下,使用Forms身份validation,标准SQL成员资格提供程序和以下代码:
// m_LoggedIn is a Literal control on the page: m_LoggedIn.Text = string.Format("
Page.User.Identity: {0} " + "
Request.LogonUserIdentity: {1}", Page.User.Identity.Name, Request.LogonUserIdentity.Name);
我得到以下输出:
Page.User.Identity:zhaph
Request.LogonUserIdentity:[ComputerName] Ben
第一行(Page.User.Identity)是我登录到站点的表单身份validation帐户,第二行是请求运行的Windows身份 – 因为我没有启用模拟,这是我的Windows登录因为这是运行Web服务器的帐户。
就API而言, HttpRequest.LogonUserIdentity调用WindowsIdentity类,它总是代表一个Windows用户帐户 ,而Page.User正在创建一个实现IPrinciple的对象,它允许您使用许多不同的支持来表示用户stores – 例如MembershipProvider提供的SQL数据库结构。
上述就是C#学习教程:Page.User.Identity与Request.LogonUserIdentity之间的差异分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/962232.html