登录后在哪里存储用户特定的设置?(Where to store a user specific setting after logon?)

编程入门 行业动态 更新时间:2024-10-23 17:29:54
登录后在哪里存储用户特定的设置?(Where to store a user specific setting after logon?)

在我的ASP.NET MVC应用程序中,我允许用户登录。每个用户都与公司相关联。 公司ID和公司数据不是数据库中Users表的一部分。 用户和公司通过相关表(一对多关系)连接。 公司ID不是Users表的一部分作为外键,因为Users表的设计没有预测到,我们不允许更改它。

当用户登录时,我们想要获取该用户的公司ID并将其存储在某个地方。 我们稍后会使用此ID进行查询以及公司的其他类型的过滤,因为内容是按公司存储的。

我应该在哪里存储公司ID设置,以使其在许多Web请求中保持不变?

In my ASP.NET MVC application I allow users to log in. Each user is associated with a company. Company ID and company data is not part of the Users table in the database. User and Company are connected through a related table (one to many relationship). Company ID is not part of the Users table as a foreign key because the design of the Users table did not predict that and we are not allowed to change it.

When user logs on we want to take the company ID for this user and store it somewhere. We would use this ID later for querying and other kinds of filtering by company because the content is stored per company.

Where should I store the company ID setting to make it persistant over many web request?

最满意答案

我看到三个可行的选择

会议

曲奇饼 这可能是也可能不是您选择的身份验证cookie。

将其保存在数据库中 在需要时查询。 如果需要的时间少于x%,只需从数据源中获取它。

I see three viable options

Session

Cookie This may or may not be in the authentication cookie, your choice.

Keep it in the database Query as and when needed. If it's needed less than x% of the time, just fetch it as and when needed from the datasource.

更多推荐

本文发布于:2023-07-31 00:05:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1340335.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用户   store   user   logon   setting

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!