user.identity.name和session ["username"]之间的区别 [英] Difference between user.identity.name and session["username"]

查看:198
本文介绍了user.identity.name和session ["username"]之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

user.identity.name和session ["username"]之间的区别是什么?

what is the diffenernce between user.identity.name and session["username"]

推荐答案

身份

如果该人已登录服务器,则只能检索该人的身份.如果IIS身份验证已关闭,则不需要身份验证,因此不会向Web应用程序提供任何身份.该网络应用必须先知道您的身份,然后才能说出您的姓名.

会话

您可能知道会话变量的默认范围默认为20分钟,这是我们在IIS服务器上设置的,我们可以根据需要进行更改
因此您的会话变量将仅可用20分钟,因此该会话变量可用于长时间保存数据,这意味着只要您的会话根据iss服务器设置有效,就可以了.
Identity

You''ll only be able to retrieve the identity of the person accessing the web app, if that person is logged in on the server. If the IIS authentication is turned off, then no authentication will be required, and therefore, no identity will be provided to the web app. The web app will have to know who you are, before it can say your name.

Session

you might be knowing that session variable has default scope of 20 minutes by default ,which we set on IIS server,we can change it according to need
so your session variable will be available for just 20 minutes ,so this session variable can be used to hold data for long time,i mean as long as your session is alive as per iss server setting


User.Identity.Name是当前用户的名称
Session["username"]是由它制成的,ASP.NET不使用它.
User.Identity.Name is the name of the current user
Session["username"] is what you make of it, ASP.NET doesn''t use it.


这篇关于user.identity.name和session ["username"]之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆