2

i hope somebody had a similar problem and can give be advice. I researched for quite some time but couldn't find a definitive answer.

My Set Up:

  • 1 MsSQL Database (contains the Identity Tables of System.Web.Security)
  • Many DLLs in .Net Framework (Using System.Web.Security for Log-In)
  • Multiple different Programs/Apps calling the DLLs
  • WebForms GUI in .Net Framework (Using System.Web.Security for Log-In)

What I want:

  • Use IdentityServer4 in .net Core or .Net Framework
  • Keep DLLs in .Net Framework
  • Use WebApi in .Net Core
  • Use a new GUI (f.ex. in Angular or Blazor)
  • Use the Old GUI in WebForms in parallel to the new GUI (until the new GUI is finished)

My Problem: My DLLs and Applications use System.Web.Security for User-Management (login etc.). This namespace is not supported in .Net Core, but to change all my DLLs to .Net Core is not feasible for me, because this would result in too many changes. I would like to keep them in .NetFramework.

One of My main Questions:

  • Can an App in .Net Core (f.ex. WebApi, IdentityServer4) and an App/Dlls in .NetFramework use the same Database for Identity (login, membership, etc.). In other word are "microsoft.aspnet.identity" and "microsoft.aspnetcore.identity" compatible (regarding the database) if used in different Apps/Dlls.
  • Or do I have to use one of the Identity-Namespaces in all apps/dlls to be compatible? (and therefore MUST use the same Framework in all apps/dlls)

I hope this was short and clear enough to describe my problem. Please let me know if something was unclear.

Update I just found this Post Microsoft.AspNet.Identity and Microsoft.AspNet.Identity.EntityFramework in .NET Standard 2.0 Maybe using .Net standard in all DLLs might be an option. I will try this and see I it will work out for me. But I still don't understand if and how "microsoft.aspnet.identity" and "microsoft.aspnetcore.identity" works in a .Net Standard library.

Result: I was able to use "Microsoft.AspNetCore.Identity", "Microsoft.EntityFrameworkCore" in a .Net Standard 2.1 Library (Microsoft.EntityFrameworkCore is supported in .Net Standard 2.1 and net Core 3.0). So this is good News (I don't have to migrate all DLLs to .Net Core just for Identity. Migrating to .Net standard would be enough). But I can't reference that .Net Standard 2.1 DLL in a .Net Framework DLL/App because .Net Framework support it up to .Net Standard 2.0... So this does not fully solve the problem, but it seems to be the closest thing to what I want to do.

Update2

I am prepared to change a lot of code for this change. F.ex. the Authentication in the old WebApp so that it talks to the IdentityServer and removing everything related to System.Web(.Security) in all projects. One thing that still confuses me is "microsoft.aspnet.identity" vs "microsoft.aspnetcore.identity". Do I have to choose one of them for all projects or can I mix those namespaces (depending on the Framework of the projects) but just keep one database.

Update3 I marked an answer because it helped for answer my basic question ("it's not possible"). I will try to implement it and see it there surface more problems. But if someone has more ideas/experiences for this topic, please feel free to share it here.

Some of the sources I used:

user3675331
  • 193
  • 1
  • 9
  • 1
    Some information about the difference: https://stackoverflow.com/questions/41140952/what-is-the-difference-between-microsoft-aspnet-identity-core-and-microsoft-aspn –  Oct 18 '19 at 12:56
  • Thanks for the reply, I already saw that one, but It just explained what namespace has to be used in .Net Core and .Net Framework but not if two applications with those two namespaces are compatible. – user3675331 Oct 18 '19 at 13:01

1 Answers1

3

Despite both having ASP.NET in the name, ASP.NET Core is an entirely different framework than ASP.NET. People don't seem to realize that this isn't just like a making a version jump: you will have to rewrite your app.

ASP.NET Membership (System.Web.Security) is deprecated and 100% unsupported in .NET Core. That's not going to change and there is no workaround here. If you want to do auth in ASP.NET Core, you'll have to start from scratch.

Since you want to use Identity Server, anyways, you can still support your legacy Web Forms app, but you'll have to move all authentication to Identity Server, and then use Identity Server as your auth mechanism in the Web Forms app. Again, this is going to require making changes to the Web Forms app. There is no other option here.

On the Identity Server side, you may opt to forgo ASP.NET Identity. Identity Server is just the auth provider; it doesn't concern itself with user management. You can technically continue to use your old user tables, but you'd have to create custom profile and user store providers for Identity Server, to enable it to do the work it needs to do. Honestly, you're better off just starting over with Identity here, than doing a bunch of work to attempt to support a user management system that was deprecated long ago.

Long and short, nothing here is trivial. If you want to do what you're talking about, you are embarking on a major project, which will require a ton of effort and changing every piece of your app. That's just the way it is. If you're not prepared for that, then stick with what you have.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
  • Hi, @Chris Pratt, I am prepared to change a lot of code for this change. F.ex. the Authentication in the old WebApp so that it talks to the IdentityServer and removing everything related to System.Web(.Security) in all projects. One thing that still confuses me is "microsoft.aspnet.identity" vs "microsoft.aspnetcore.identity". Do I have to choose one of them for all projects or can I mix those namespaces (depending on the Framework of the projects) but just keep one database. – user3675331 Oct 18 '19 at 14:08
  • 1
    The difference is in the namespaces, `aspnet` v. `aspnetcore`. Again, totally different frameworks, so totally different versions of Identity for each. For new stuff, and especially if you intend to use the Identity integration in Identity Server, you'll need the .NET Core version. – Chris Pratt Oct 18 '19 at 14:11
  • Okay, now I see. So basically I need to use "Microsoft.AspNetCore.Identity" and ""Microsoft.EntityFrameworkCore" in all Projects, which means I can't use .Net Framework anymore (Maybe .Net Standard as I posted - i need to try this out). I will try to spend more time to understand why it is not possible. Because I thought that in the end the Users and Groups are just stored in the Database and i "just" need to access them "somehow" and a complete framework change is a bit overkill for "just" that one thing. – user3675331 Oct 18 '19 at 14:18
  • 1
    It's worth mentioning that .NET Core 3.0 is not compatible with any version of .NET Framework. If you need to keep some stuff in .NET Framework, you'll need to stick to 2.2. – Chris Pratt Oct 18 '19 at 14:47