ASP.Net MVC、基于角色的安全性和其他基于人员的数据

发布于 2024-08-03 11:16:21 字数 262 浏览 1 评论 0原文

我有一个 ASP.Net MVC 应用程序,并且在 SQL Server 中使用表单身份验证。这为我设置了身份验证和授权。但是,我还需要跟踪其他基于人员的数据,例如人员的电话号码、部门、收费率、开始日期等。

人员可以做什么(由 ASP.Net 控制)安全性)与他们是谁有关(由我的应用程序控制)。

是否有将 ASP.Net 与我的应用程序数据链接以获得更完整的人员对象的最佳实践?我可以简单地扩展 ASP.Net 表中的信息吗?是不是把它分开比较好?有人有任何提示或指导链接吗?

I have an ASP.Net MVC application and I'm using Forms authentication in SQL Server. This sets up the authentication and authorization for me. However, I have other person-based data that I need to track as well, such as the person's phone number, department, their charge-out rate, start date, etc.

WHAT the person can do (which is controlled by ASP.Net security) is related to WHO they are (which is controlled by my application).

Is there a best practice for linking ASP.Net with my application data to get a more complete person object? Can I simply extend the information in the ASP.Net tables? Is it better to keep it separate? Has anyone got any tips or links for guidance?

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

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

发布评论

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

评论(2

把人绕傻吧 2024-08-10 11:16:21

由于您已经在使用 ASP.NET 表单身份验证,因此 ASP.NET RoleProvider 可以通过 授权属性也同样易于设置。

你会得到这样的结果:

[Authorize(IsInRole="Chef")]
public ActionResult Cook() { // snip ...

如果你确实使用了所有这些,还有 ProfileProvider for ASP.NET,它为您生成配置文件代码,并提供完整的智能感知支持。您可以自定义您想要的字段以及应存储的数据类型等。

角色提供程序和配置文件提供程序都可以自定义或自定义,互联网上有很多文章会告诉您如何操作。

使用 ASP.NET 提供程序还为您带来了以下好处:数据在整个 ASP.NET 请求处理管道中自动维护,例如,您可以访问此属性:

HttpContext.Current.Profile

...几乎从任何地方。

Since you are already using ASP.NET Forms Authentication the ASP.NET RoleProvider which can be integrated into MVC via the Authorize attribute is just as easy to setup.

And you get something like this:

[Authorize(IsInRole="Chef")]
public ActionResult Cook() { // snip ...

And if you did use all that, there's also the ProfileProvider for ASP.NET which generates profile code for you with full intellisense support. You can customize which fields you want and what data types it should be stored in etc. etc.

Both the Role Provider and Profile Provider can be customized or roll-your-own, there are many many articles on the internet that will tell you how.

Using the ASP.NET providers also gives you the benefits that the data is maintained automatically throughout the ASP.NET request processing pipeline, e.g. you can access this property:

HttpContext.Current.Profile

...from almost anywhere.

洛阳烟雨空心柳 2024-08-10 11:16:21

使用配置文件属性的内置功能来存储有关的其他数据您的用户。

Use the built-in functionality for Profile Properties to store additional data about your users.

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