英文:
Sharing cookie authentication from ASP.NET 5+ application to legacy ASP.NET 4.x
问题
I searched and found some examples mentioning the sharing of authentication cookies between .NET Framework and .NET Core/5+ applications, but most of citations are of cookies being generated in the older version of .NET being reused in Core, not the opposite that is what I need.
The closest case was this one.
But the version of reference is seems .NET Core 2.1 and some methods in the answer has been deprecated and I couldn't reproduce it. Also seems the authentication being performed in older application.
How could I setup a web app in ASP.NET 7 with individual accounts authentication and reuse this cookie to authorize other applications (legacy 4.x web apps modules, and also newer applications that'll be implemented)?
英文:
I searched and found some examples mentioning the sharing of authentication cookies between .NET Framework and .NET Core/5+ applications, but most of citations are of cookies being generated in the older version of .NET being reused in Core, not the opposite that is what I need.
The closest case was this one.
But the version of reference is seems .NET Core 2.1 and some methods in the answer has been deprecated and I couldn't reproduce it. Also seems the authentication being performed in older application.
How could I setup a web app in ASP.NET 7 with individual accounts authentication and reuse this cookie to authorize other applications (legacy 4.x web apps modules, and also newer applications that'll be implemented)?
答案1
得分: 0
The middleware UseCookieAuthentication
is obsolete. Configure Cookie authentication with AddAuthentication().AddCookie
When you regist the service ,and call app.UseAuthentication()
middleware, Here's the document related
You could try as below in your .net core project and follow the case you provided
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(x =>
{
x.DataProtectionProvider = DataProtectionProvider.Create(new DirectoryInfo(.......);
});
app.UseAuthentication()
英文:
The middleware UseCookieAuthentication
is obsolete. Configure Cookie authentication with AddAuthentication().AddCookie
When you regist the service ,and call app.UseAuthentication()
middleware,Here's the document related
You could try as below in your .net core project and follow the case you provided
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(x =>
{
x.DataProtectionProvider = DataProtectionProvider.Create(new DirectoryInfo(.......);
}
);
.....
app.UseAuthentication()
......
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论