在我的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.
更多推荐
发布评论