默认会员资格和用户分析与自定义会员和用户分析

发布于 2024-08-12 12:20:21 字数 555 浏览 1 评论 0原文

我刚刚浏览了“AccountController.cs”代码(创建新的 ASP.NET MVC 项目时出现的默认代码)。当我尝试将其与我书中提出的控制器进行比较时,我注意到这两个控制器共享相同的概念并实现相同的方法(LogOn、LogOff、CreateUser、DeleteUser、ChangePassword 等)。 >)。 现在,我想知道为什么有人想要创建自己的 AccountController 来替换默认的。

几乎所有的书籍(甚至是专业书籍)都不建议我们创建一个 AccountController。但是,其中一个(啤酒屋)花了整整一章的时间来讨论如何实现这一点。我真的很喜欢它,因为能够看到真正的专业项目的代码。但是,如果这是一个非常大的网站的内容,我最好把学习时间花在其他科目上。

我的问题是:对于一个专业网站(不是很大),使用默认的AccountController安全吗?或者我绝对需要创建一个新的。 (最重要的是)为什么?默认控制器有什么限制???我可以对默认的功能进行一些增强,以防只是为了满足特定的需求吗?

谢谢

I was just going through the "AccountController.cs" code (the default one which appears when you create a new ASP.NET MVC project). When I tried to compare it to the one that is proposed in my book, I noticed that the two controllers share the same concepts and implements the same methods (LogOn, LogOff, CreateUser, DeleteUser, ChangePassword, etc.).
Now, I'm wondering why someone would want to create an AccountController of his own to replace the default one.

Almost, all the books (even professional ones) do not suggest we should create an AccountController. But, one of them (The Beer House) spend a whole chapter on how to implements just that. I really liked it as was able to see a real professional project's code. But, if it's a stuff for very big big website, I might be better off spending my learning time in other subjects.

My question is this one: For a professional website (not very big big), is it safe to use the default AccountController? Or I need absolutely to create a new one. And (most importantly) why? What are the limitations of the default controller??? Can I provide some enhancement to the default one in case it's just a matter of making it specific to address a need?

Thank you

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

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

发布评论

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

评论(2

嘴硬脾气大 2024-08-19 12:20:21

通常您需要重写或至少在默认的 AccountController 中进行许多更改。例如:

  • 默认 AccountController 允许任何人注册(创建新帐户),无需任何电子邮件确认甚至验证码。
  • 默认注册只需登录名、电子邮件和密码。通常您希望根据特定应用程序调整用户配置文件数据。
  • 没有“忘记我的密码”选项
  • 没有“编辑个人资料”选项。
  • 我不知道将数据库架构与自动生成的表(aspnet_XXX)集成是否是一个好主意。如果您的数据库模式中有自己的“Users”表,那么最好使用自己的“Users”表编写自己的 MembershipProvider。
  • 默认配置文件提供程序以不直观的方式存储配置文件数据(没有每个配置文件字段包含一列的表)。

Usually you will need to rewrite or at least make many changes in the default AccountController. For example:

  • Default AccountController allows anybody to register (create new account) without any email confirmation or even CAPTCHA.
  • Default registration needs only login, email and password. Usually you would like to adjust user profile data to specific application.
  • There is no "forgot my password" option
  • There is no "Edit profile" option.
  • I don't know if it is a good idea to integrate your database schema with autogenerated tables (aspnet_XXX). If you have your own "Users" table in your database schema maybe it is better to write your own MembershipProvider using your own "Users" table.
  • Default profile provider stores profile data in not intuitive way (there is no table with one column per profile field).
π浅易 2024-08-19 12:20:21

这是一个很难回答的问题。您需要列举任何特定的需求、要求或一般的有趣之处,并将它们与您已经完成的内容进行比较。如果你连接了现有的并且它非常适合你,那么可能没有理由编写新的东西。

That's a tough question to answer. You need to enumerate any specific needs, requirements, or general funkiness and compare them to what you already have completed for you. If you wire up the existing and it suits you just fine, there's probably no reason to write something new.

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