将用户会话信息添加到 HTTPContext

发布于 2024-12-13 03:59:34 字数 56 浏览 2 评论 0原文

我现在有一个用户类,我想将该类添加到 HTTPContext 对象,以便每次发送请求时我不必验证它

I am Having a User Class now i want to add that class to HTTPContext object so that each time i send a request I don't have to validate it

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

娇妻 2024-12-20 03:59:34

ASP.NET 有多种状态管理方法 - 您需要选择最适合您需要的一种,然后仅存储一次经过验证的用户凭据。

如果您只有一个服务器设置,并且将来看不到对多个服务器/网络场的需求,您可以考虑使用 ASP.NET 会话状态

会话状态使用服务器上的进程内内存 - 因此,如果您将请求分散到多个服务器,则此方法将不起作用。然后,您可以考虑在数据库中存储身份验证令牌。您可以混合使用两者 - 在数据库中存储会话状态

最后,您可以考虑使用 ASP.NET Membership,它可以简化工作创建和管理用户、身份验证和授权。

ASP.NET has several state management approaches - you need to choose the one most suitable to your need, and then store your validated user credentials once only.

If you have a single server setup, and can't see the need for multiple servers / a web farm in the future, you could consider using ASP.NET Session State.

Session State uses in-process memory on the server - so if you are spreading requests to multiple servers, this approach won't work. You would then consider storing an authentication token in your database. You can have a mixture of the two - storing session state in the database.

Lastly, you could consider using ASP.NET Membership, which simplifies the job of creating and managing users, authentication, and authorization.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文