English 中文(简体)
Default Membership and User Profiling vs Custom ones
原标题:

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

最佳回答

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).
问题回答

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.





相关问题
WebForms and ASP.NET MVC co-existence

I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...

Post back complex object from client side

I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...

Create an incremental placeholder in NHaml

What I want to reach is a way to add a script and style placeholder in my master. They will include my initial site.css and jquery.js files. Each haml page or partial can then add their own required ...

asp.net mvc automapper parsing

let s say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; ...

structureMap mocks stub help

I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor)...

ASP.NET MVC: How should it work with subversion?

So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

热门标签