asp.net mvc的 - 在哪里存储用户ID - 整数? [英] asp.net mvc - where to store userid - integer?

查看:95
本文介绍了asp.net mvc的 - 在哪里存储用户ID - 整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用会话变量在ASP.NET MVC是那种看不起氛围。

I got the vibe using session variable is sort of looked down upon in ASP.NET MVC.

一旦用户登录时,我想保留用户的用户id,这样我就不必查询它所有的时间等。

Once a user logs in, I would like to retain the user's userId so that I do not have to query it all the time etc.

什么是最有效的方式做,在ASP.NET MVC?

What is the most efficient way to do that in ASP.NET MVC?

推荐答案

我见过类似的问题在一段时间后弹出,我无法揣摩出这种氛围的来源。这是会话是专为设计 - 用于存储会话相关的信息。但绝对没有错,使用会话来存储用户ID或类似的信息。

I have seen similar questions pop up once in a while and I can't figure out where this "vibe" is coming from. This is what Session is specifically designed for - for storing session-related information. There's absolutely nothing wrong with using Session to store a user id or similar information.

这篇关于asp.net mvc的 - 在哪里存储用户ID - 整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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