ASP MVC 5 (Microsoft.AspNet.Identity) User Management Package - asp.net-mvc

Does asp.net mvc5 really not come with some sort of default controllers and views to manage your users? things like creating a new role, and then assigning it to a user etc etc?
Is every single mvc5 website supposed to code their own?
Over and over again?
I get that we can now add custom fields etc to our users, but surely some sort of simple base built in manager isn't asking for too much?
Is there some magical nuget package or something I'm missing?

There doesn't seem to be anything like this.
I have added an item onto the asp.net uservoice list and you can vote for it there.
I'm marking this as closed.
http://aspnet.uservoice.com/forums/41201-asp-net-mvc/suggestions/5009231-add-a-default-asp-mvc-5-microsoft-aspnet-identity

Related

Ready to use admin views for ASP.NET MVC project?

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.

How to add second application to MVC website

Say I've got an MVC website, www.codesmurf.com for example, set up with default ASP.NET MVC routing, nothing fancy. So my BlogController can be found at www.codesmurf.com/blog, and my FAQ similarly at www.codesmurf.com/faq.
Now if I also have a small survey project, currently in a different solution, how would I achieve to access this survey at www.codesmurf.com/survey?
What changes would I have to make to my routing and/or project structure to achieve this? So the entire survey project would be at the controller level of the main website, judging by the uri.
Do I have to achieve this using Areas? Do I need to create a SurveyController on the main site to redirect internally? Do I need to host this website separately and redirect externally? Any IIS configurations? How do I make sure my old routing isn't messed up?
This seemed like an easy task in my head at first, but I really have no clue what the best way to achieve this would be, and questions keep popping up in my head the more I think about it.
Note that the survey site is also an MVC project with its own controllers etc..
I haven't had much experience with changing the MVC routes, but would like to understand what I'm doing as well, so context/explanation would be greatly appreciated.
I personally would add the survey functionality as a service reference to your current MVC project.
Add Areas/Survey to your current MVC project and then start using the code from the service reference as you build up the Survey area.
When adding areas, all you will need to do is add some more rules to your map routes.
routes.MapRoute("areaRoute", "{area:exists}/{controller=Home}/{action=Index}/{id?}");

Integrate Umbraco in an MVC and not the other way round

I have little to no experience in Umbraco, but it has been suggested to me as I have been asked to integrate a CMS system within my existing application. I have gone through some videos how to use Umbraco and done well so far. The problem is as follows. I have an existing MVC application with custom routing but both use the same database and dll. Example: www.ngomalta.com and animalguardians.ngomalta.com
Both have same interface, but with custom routing I can load some pages on a subdomain but not in the other. I would like to implement the same 'logic' using Umbraco. That is, I want both sites to have access to umbraco but they would have different content. Please note that it may be that I would have other sub domains in the future such as tomasina.ngomalta.com, and thus I would like scalability.
I have had a look on the net and other answers. However the solutions that I found are vice versa! What I mean is, that solutions given assume that you have an Umbraco site and you want to add an MVC controller. My situation is the opposite, I have the MVC and would like to add Umbraco views. Thus I want to make Umbraco compatabile with MVC and not design an MVC solution to be compatible/integrated with Umbraco.
Currently I have implemented a class that Inherits UmbracoApplication + WebBootManagerand and which overrides the Complete function. I have also tried to use my existing custom routing class (that inherits from [RouteBase]). It looks as if they work.. but the CSS styles and javascripts are not sort of routed or I don't know. They just aren't sent to the client. hence only the HTML is sent for both Umbraco page and my existing MVC views
First of all, is my idea with Umbraco possible?
If yes, can someone guide me some site that implements Umbraco in an existing (LIVE) MVC application and not the other way round? many of the tutorials that exist always start from a blank MVC application and build on that. I don't want such tutorials. I need a tutorial, that shows how an existing MVC application with already-existing-controllers that tries to integrate Umbraco.
Thanks for reading people..
!

Associating Data with authenticated user in ASP.NET MVC optimization

I am using ASP.NET WebAPI with the built in authentication and identity services that come with the Visual Studio template. I now have it that a user can access the system and be authenticated.
The next logical step is to allow the user to create records. Lets say the user can have a "Project". How can I associate the user with a project at the point the project is created? It seems logical that the project table will just store the user_id provided by User.Identity.GetUserId().
Now, say that a project consists of Tasks. By default the WebAPI will create a Tasks controller, where I post a task. I think I would need to inject some additional information (such as the project id) at the point of creating the task.
But, say someone wants to add a task a project that doesn't belong to them. I need to verify this by loading the project, and checking the user_id field. Now I am adding two repositories to my controller. This seems like a lot of work.
Is it my own laziness that makes this seem hard???
I think this might be a related question, as it seems like you are looking for record-level authorization.
MVC / ASP.Net Best Practice for Record-Level Authorization
There is merit also in using multiple repositories. See here for an example of use.
http://www.asp.net/mvc/overview/older-versions/getting-started-with-ef-5-using-mvc-4/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application
Here, you would wrap the multiple repositories up within the UnitOfWork class.
I hope this points you in the right direction.

MVC - Implement members online functionality

I have an ASP.NET MVC app and I want to add
to each page a list of members online. Actually add to Master page.
Members belong to groups so I want to
show all members in there groups.
So what is the best way of doing this??
Eg On session start add to a collection that is in cache object
and remove it on session end in Global.asax.
Is that a reliable way??
Traffic wont be enormous.
Malcolm
See How can I determine the number of users on an ASP.NET site (IIS)? And their info? The same approach can be used for WebForms as well as ASP.NET MVC.
Yes, you'll have to use the Application object to store it,
and you could do it in the Session Start/Session End events.
Add to the Application on Start, and remove on End.

Resources