What is the difference between MVC5 identity and MVC4 simple membership? - c#

I am building an MVC 5 application and the build in membership function in a basic MVC 5 project is MVC5 Identity. I am familiar to MVC 4 simple membership, but i want to use the new functions of MVC 5. The identity seems a little lean and you have to extend everything.
Can you tell me which one is better for application that needs to handle multiple logins - 1k+
and open authentication ?

Can you tell me which one is better for application that needs to
handle multiple logins - 1k+ and open authentication ?
Currently, ASP.Net Identity reaches to Version 2 already, so we can assume that SimpleMembership Provider is deprecated.
Unfortunately, Identity is not backward compatible with SimpleMembership Provider.
If you are implementing new Application with MVC 5, you definitely want to use new Identity 2.

Related

Making identity providers in ASP.NET MVC and ASP.NET CORE co-exists

I have migrated a ASP.NET MVC project to ASP.NET Core and currently testing it.
I would like to keep the current version and the new version using the same database during these testing and staging phases.
Both apps uses ASP.NET identity providers. When we have green light, we put the new app in production while the database is already in place.
To make the database work in ASP.NET Core, I had to do some changes, like adding new columns for some normalized values and add the AspNetRoleClaims table as well. After that .NET Core works fine, but the old application is failing authentication at login operation.
My desktop client applications are also failing to get the authentication bearer tokens. I read something that bearer tokens are no longer default in .NET Core 3.1.
Not sure how and if these two problems are related, but is there any changes I could make this work, so I could make a smooth transition?
Your need:
Making identity providers in ASP.NET MVC and ASP.NET CORE co-exists.
It's worse practice. Because your mixed system is not unified, many errors. Let's try to migrate to ASP.NET Core with (ASP.NET Core Identity) totally.

Is it possible to add ASP.NET Core Identity to a WebForms project?

I know it is possible to add ASP.NET Identity (note NOT Core) to a WebForms project. But what I want to do is add ASP.NET Core Identity to an existing WebForms project.
Is this possible?
If 1. is not possible, then how do I share an ASP.NET Core Identity user database between my .NET Core application and WebForms application so that I can implement https://learn.microsoft.com/en-us/aspnet/core/security/cookie-sharing?view=aspnetcore-2.2#use-a-common-user-database
It is definitely possible to share the database
Option 1: you will need to do some custom implementation since Core Identity (v3) might have a slightly different schema than .NET Framework Identity (v2). Take a look at the following link https://learn.microsoft.com/en-us/aspnet/identity/overview/extensibility/index
You might need to also override the PasswordHasher if they are different implementations. Check the following article out: https://andrewlock.net/exploring-the-asp-net-core-identity-passwordhasher/
Option 2: You can expose login/registering/membership functionality from your Core project and consume from your WebForm as a rest service. There are several rest security schemes and middleware.
See:
https://garywoodfine.com/asp-net-core-2-2-jwt-authentication-tutorial/
https://learn.microsoft.com/en-us/dotnet/standard/microservices-architecture/secure-net-microservices-web-applications/
Those are a few quick ones. You can probably extrapolate and get some other ideas from looking at the source for Identity lib (https://github.com/aspnet/AspNetCore/tree/master/src/Identity) If you scroll down the readme you'll see different Store providers. For Option 1 you would need to essentially write a Core Store for your Web Forms Identity lib (https://archive.codeplex.com/?p=aspnetwebstack)

ASP.NET Core 2.0 Using old ASP.NET 2.0 database structure for authentication

So I've been developing an ASP.NET Core 2.0 application for a while now and I was wondering if it's possible to use an older SQL database with the following tables in my ASP.NET Core 2.0 application.
As I read online this is the default database structure for using ASP.NET 2.0 SqlMemebershipProvider classes. Is it possible to implement this into my application and if so, how should I approach this?
The structure you talk about is called ASP.NET Membership and it works for any ASP.NET version, up to 4.5.
There's no built-in way to run Membership in ASP.NET Core because Membership has been dead for many years. You have two paths to follow:
Move to ASP.NET Identity, works for both ASP.NET 4.x and Core. You will need to migrate your data manually.
Create the classes to consume the data manually. Notice that you won't have any of the security features of Membership so I strongly discourage this.
Of course, a 3rd path would be to keep using the outdated Membership on an ASP.NET MVC 5 application.
The old table structure is not compatible with ASP.NET Identity. Plain and simple. Your best path forward is to generate the tables that Identity does use, and then migrate the data from the old tables to those. Nothing else will work.

Is OWIN only for ASP.net Identity? Can't we use owin context to query our application db?

I am very new to EF, ASP.Net MVC, ASP.net Identity etc.
I am creating a simple e-commerce website for learning above mentioned stuff. My query is, how can I query the application database?
Is OWIN context only used for ASP.net Identity?
Yes, that context should only be used for asp.net identity
OWIN and asp.net identity are completely separate concepts :
ASP.Net Identity : This framework is used for user management/authentication mechanism etc. For more detail please Follow this link
OWIN : Owin defines an abstraction between .NET web servers and web applications. By decoupling the web server from the application, OWIN makes it easier to create middleware for .NET web development. Also, OWIN makes it easier to port web applications to other hosts—for example, self-hosting in a Windows service or other process. For more information follow this link
Now what you are trying to do is that you want to use entity framework to query the database in various scenarios. So for that you should create a custom context, define your schema in it and do whatever query you want to do over that.
To know more about entity framework you can start from here

Asp.net MVC2 login to MVC5 login

I got a MVC2 project that I would like to upgrade to MVC5.
I would like to use the new asp.net owin and asp.net identity.
How ever if I would go ahead and make a new asp.net MVC5 project I would probably need to redo my database. And my database is rather big and complex, would it be possible somehow to generate new controllers from my existing database ?
Or would it just be easier to stick with the current login system I already use ? (asp.net mvc2)

Categories

Resources