我必须使用“ASP.net 配置”吗?管理用户的工具?
我刚刚在 asp.net 上浏览新的 MVC 音乐商店教程。最后步骤之一是添加“会员资格和授权”。该教程让我启动了一个似乎与我的网站没有任何关系的配置工具。
两件事:
- 我使用该工具创建的用户存储在哪里?
- 我可以绕过该工具并实现我自己的东西吗?
如果我能够执行上述 2 项操作并绕过该工具,我是否仍然可以使用注释,例如:
[Authorize(Roles = "Administrator")]
工具可能不明确。我指的是 ASP.Net Web 应用程序管理工具。它是一个蓝色和白色的网页,顶部有一些选项卡(主页、安全性、应用程序、提供商)。
I was just going through the new MVC Music Store tutorial at asp.net. One of the last steps is to add "Membership and authorization". The tutorial has me launch a configuration tool that doesn't seem to have anything to do with my site.
2 things:
- Where do the users I create using that tool get stored?
- Can I bypass that tool and implement my own thing?
If I am able to do 2 above and bypass the tool am I still allowed to use the annotations such as:
[Authorize(Roles = "Administrator")]
Tool may be ambiguous. I am referring to the ASP.Net Web Application Administration Tool. It's a blue and white web page with some tabs across the top (Home, Security, Application, Provider).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它的工作方式与 ASP.NET 成员资格和角色一直以来的工作方式相同,并且实际上使用相同的系统。关于这个主题已经有无数的问题,快速谷歌也会找到大量的文章。
具体来说,asp.net 工具将数据库中的用户存储在 aspnet_* 表中。是的,您可以绕过它并实现您自己的,尽管这通常不是必需的。 asp.net 工具只是管理此过程的快速且简单的工具,您可能必须实现自己的工具。
是的,您仍然可以使用 AuthorizeAttribute.. 再次,它是 asp.net 提供的通用成员资格和角色系统的一部分(有大量相关信息)。
It works the same way as ASP.NET Membership and Roles have always worked, and in fact uses the same system. There are already tons and tons of questions here on the subject, and a quick google will also find tons of articles.
To be specific, the asp.net tool stores users in the database in the aspnet_* tables. Yes, you can bypass it and implement your own, though that isn't typically necessary. The asp.net tool is just a quick and easy tool to manage this process, and you will likely have to implement your own.
Yes, you can still use the AuthorizeAttribute.. again, it's all part of the generic Membership and Roles system provided by asp.net (which there is tons of information about).
我建议构建您自己的用户配置作为应用程序的一部分,考虑构建映射到您自己的数据库的自定义成员资格提供程序(和自定义角色提供程序),当您需要执行配置工具的操作时,这将很有用做不到。 ASP.NET 身份验证基于这些,并允许您使用所有内置授权。
I would suggest building your own user configuration as part of your application, look into building a custom Membership Provider (and custom role provider) that maps to your own database, this will be useful going forward when you need to do things that the Configuration tool cannot do. ASP.NET authentication is based around these and will allow you to use all the built-in authorisation.
如果您的用户不仅仅只有姓名和电子邮件地址,您不必使用它,也不想使用它。如果您确实使用它,那么它是添加初始角色或关键用户的起点。因为有许多具有不同含义的提供商选项,您将可能需要进行大量的自定义编程。例如,您的
enablePasswordRetrieval
、enablePasswordReset
或requiresQuestionAndAnswer
设置将开始决定您需要适应的操作类型。搜索 ASP.NET 成员资格与 MVC 结合应该会引导您找到最适合您的项目的方法。我最近添加和修改了基本 ASP.NET MVC 帐户控制器操作,以便用户管理其帐户(包括电子邮件验证、重置忘记的密码以及更改安全问题/答案),并且同样重要的是创建用户具有帮助管理员对用户执行维护(分配角色、解锁帐户或重置密码)的操作的控制器。
如果您打算的话,我建议您查看 Web Profile Builder 来获得对配置文件数据的强类型访问存储有关用户的更多信息(例如名字和姓氏等)。令人有点惊讶的是,在这一特定方面,开发人员需要实现多少工作。
You do not have to use it, nor would you want to if your users have more than just a name and email address. If you use it at all, it's a starting point to add your initial roles or key users. Because there are a number of provider options that have different implications you'll likely have to do a lot of custom programming. For example, your settings for
enablePasswordRetrieval
,enablePasswordReset
, orrequiresQuestionAndAnswer
would start to shape what sort of actions you would need to accommodate.A search for ASP.NET Membership paired with MVC should lead you to what will work best in your project. I've recently gone through adding and modifying the base ASP.NET MVC Account Controller actions for users to manage their account (including email verification, resetting forgotten passwords, and changing security questions/answers) and--equally important--creating a Users Controller with Actions that help administrators perform maintenance on users (assigning to roles, unlocking accounts, or resetting passwords).
I would recommend looking at Web Profile Builder to gain strongly-typed access to profile data if you intend to store more information about your users (like first and last name, etc). It is a bit surprising how much is left up to the developer to implement in this particular regard.