Ready to use admin views for ASP.NET MVC project? - asp.net-mvc

I have a an ASP.NET MVC5 project using Entity Framework. I have all the regular membership entities (AspNetUser, AspNetRole, ...). In the RoR or Django world we can add admin views extremely easily and I wonder if the ASP.NET MVC eco-system has anything similar to offer.
I'm thinking about admin views for tasks as listing users, editing user's roles, changing user fields, etc. within the standard membership realm.
I know I could scaffold views (with more plumbing code than what I'd use with Django), but I'm pretty sure I wouldn't be the first one who'd create views for managing users for standard ASP.NET MVC membership setup. I made more than enough Google searches, but I only find articles about the membership provider system.
Ideally I'm looking for a NuGet package.

I'm afraid currently we don't have one but you can use https://code.msdn.microsoft.com/ASPNET-MVC-5-Security-And-44cbdb97 project to work as your administration.

Related

MVC Simple Membership Web Site Administration Tool

I must have missed this somewhere (or slept through the class)... the standard ASP security tool for managing users and roles seems to be absent when using the new simple security version. That is, the original is there and working, just points to traditional ASP security... NOT to the new "simple" system.
In my project I can log in, I can look at the webpages_ tables but can find no method of accessing them in my project... I would be happy to manage roles and get the USERID and maybe ROLEID so I could tie the user to other functions in my project.
I've looked through hundreds of posts and articles... normally I find I am missing some minor config entry or something but this time I am a little more stuck.
Advice is appreciated.
Thanks!
SimpleMembership does not work with the Web Site Administration Tool (WSAT). There is a good overview of SimpleMembership in this blog. Here is a quote from it.
WSAT is built to work with ASP.NET Membership, and is not compatible with Simple Membership. There are two main options there:
Use the WebSecurity and OAuthWebSecurity API to manage the users and
roles.
Create a web admin using the above APIs.
Since SimpleMembership
runs on top of your database, you can update your users as you would
any other data - via EF or even in direct database edits (in
development, of course)
I would also add that you can seed some of this information at application start-up, such as what roles are available, as shown in this article.

Asp.net MVC 4 EF Code First Membership Providers for Beginners

Though I asked few questions about the how to use membership providers with ASP.NET MVC 4 but hardly got any response. It is taking me time (as a newbie) to get started with membership providers in ASP.NET MVC 4. I have been reading article, trying stuff but that only added to the confusion rather than helping.
What would be the answers to the following queries by a beginner:
I want to try all the membership providers (including the simple membership provider) before deciding which one should I use for which project. What membership providers can I use with ASP.NET MVC 4 and How can I configure each one of it. Any documentation or links?
Though the internet template comes with pre-configured Account controller which sets the membership functionality, but how can I add membership functionality to the basic template. What steps should I follow in order to configure membership using membership providers (I assume there will be different set of steps/configuration/settings for different membership provider).
Running the ASP.NET MVC 4 project created with internet project template (without making any changes to it) create 5 tables in the database namely UserProfile, webpages_Membership, webpages_OAthMembership, webpages_Roles, webpages_UsersInRoles). In AccountModel.cs I see definition for only one, UserProfile. Where are the other tables defined. Do I always need to have all these tables in database in order to use membership. Can I customize them, rename them or choose not to use some of them?
I do not see any membership configuration in web.config for the internet project template yet is using membership. In some of the articles tutorial I saw people configuring it by adding <membership></membership> to web.config. When do I need to add configuration settings to web.config and when do I need not?
I think membership providers are meant to make developers life easy yet for me it is making it more difficult.
I know I really need to study it and that's what I am trying for the last 7, 8 days but unable to figure out.
Any help, links (hopefully not those which I went through many times) are more than welcome.
I agree with you, the guidance around what membership types do what just sucks.
You can use any of the providers with ASP MVC. The default template in Visual Studio that is the Internet MVC app is the only one that uses SimpleMembership.
Good question, I've not found any explicit, decent documentation on that at all. As far as I can tell most of the membership things are setup very similar.
At least SimpleMembership will create the needed DB tables that are required if they do not exist. I think the only one you can really customize is your user table.
I think like the sql tables, the membership tags in the web.config are implied. If you accept the defaults they magically work.
Best link I've found is this
http://blog.longle.net/2012/09/25/seeding-users-and-roles-with-mvc4-simplemembershipprovider-simpleroleprovider-ef5-codefirst-and-custom-user-properties/
In that post there are two others that are helpful as well.
For question 3, I tried something and it turned out that:
Yes: You can add new columns to UserProfile (and all other tables, I guess)
No: You cannot rename the table, even if u have modified the codes in AccountModels to match new table names.
In this case, a set of tables with old names will be created again when you launch application. And all codes provided by MVC4(MembserShip, WebSecurity, Users, Roles....) will used the old tables.
And, I have never found any information about how to rename these tables.

Creating MVC Application That Can Easily Integrate Into Existing Applications

I have created a custom MVC Forum application. But I'm starting to think that although it works great as is, I'm going to need to get it to work within other MVC apps (In fact I have actually been asked that already).
What is the best way with an MVC app to structure/develop to make it as easy as possible to integrate into an existing MVC application?
Areas? Develop within a sub folder from the start? Or is it just you have to work through and merge configs/controller clashes if necessary.
No need to Config or ... . you only need to create ability in your Logon Model and it's Controllers. A complete example is in Asp.net MVC 4 which Microsoft has added more libraries for authenticate from other sites/profiles. Also the model has changed a few in properties. see this technology or download MVC 4 framework to learn it. it's easy.

How to handle membership in an ASP.NET MVC application?

How would you handle membership in an ASP.NET MVC application? Using any external libraries? How would you do OpenID log in? username log in? email log in? any other that is worth looking into? Maybe all of them mixed into the application?
It seems ASP.NET comes with some pre-build user database (I'm totally new to .Net). The NerdDinner example uses it but then it makes the foreign keys use the username. That doesn't sound very good. Do you use this schema of two separate databases or only one? What do you use as the foreign key, any IDs?
I've found ASP.Net MVC Membership, anybody using it? does it work well? can it be expected to be maintained?
Membership Providers are not new to ASP.Net MVC, they were introduced with ASP.Net 2.0.
The Membership Provider model is simply an abstraction layer between your application and whatever source you are authenticating your users against. You can switch providers easily by simply changing your web.config file.
It is easy to write a membership provider, there are many walkthroughs on the web. Typically you would do so if you were using a database that used a different schema than the default examples that come with ASP.Net (which is most of the time). The foreign keys on the username thing in the NerdDinner example is a simplistic example that you would rarely see on any real-world databases.
I would highly recommend using the Membership model. Controls like the Login control are built to make use of it, and it is well-designed and makes it easy to change or combine different login methods for your application. If you want to use OpenID, a quick google search brought up this OpenID Membership Provider.

How should I implement user membership in my ASP.NET MVC site?

I'm creating an ASP.NET MVC site and I need to implement login and membership functionality.
Is this something where I roll my own? I already have a members table in my database, should I create a username and password hash field and just check against it? What about keeping the user logged in with a cookie that expires?
Is this an instance when you would use ASP.NET's built in Membership service?
ASP.NET MVC neophyte seeks help.
When you create a new ASP.NET MVC site, it already has membership built in. The CodePlex project mentioned in the other reply is only needed in special cases, namely:
You are using an early beta of the MVC framework, which doesn't have the membership feature.
You want to use an authentication system like OpenID, which isn't supported "out-of-the-box" with MVC.
You want membership administration features not included "out-of-the-box"
However, like I said, basic membership functionality is already present in an MVC site. Just add the [Authorize] attribute to any action requiring login. This is regular forms authentication, so you configured in Web.config like a non-MVC site (specifying the database, etc.; there's lots of information on the web about this).
A default MVC site will contain an "Account" controller and views which you can customize to fit your needs.
To answer the obvious question, no, you should not "roll your own." Even if you need custom authentication, it would be better to create a regular ASP.NET membership provider than to create an entirely new membership framework.
Update: The CodePlex project was updated to work with MVC 1.0
If you want to use something safe to start off with, either use the new project's template membership or consider using http://www.codeplex.com/MvcMembership.

Resources