Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When I upgrade from ASP.NET Core 1.x to 2.0, what is the replacement for IdentityCookieOptions?

I have an ASP.NET Core 1.1 application that with code that uses this API:

Microsoft.AspNetCore.Identity.IdentityCookieOptions

When I attempt to upgrade to ASP.NET Core 2.0, the compiler gives me this error:

error CS0246: The type or namespace name 'IdentityCookieOptions' could not be found (are you missing a using directive or an assembly reference?)

What is the equivalent API in ASP.NET Core 2.0?

like image 673
natemcmaster Avatar asked Jul 19 '17 22:07

natemcmaster


People also ask

Which ASP.NET Core no longer depends on the system?

Fast: ASP.NET Core no longer depends on System. Web. dll for browser-server communication. ASP.NET Core allows us to include packages that we need for our application.

What is difference between .NET Core and .NET framework?

. Net Core does not support desktop application development and it rather focuses on the web, windows mobile, and windows store. . Net Framework is used for the development of both desktop and web applications as well as it supports windows forms and WPF applications.


1 Answers

This API was removed in this change: https://github.com/aspnet/Identity/pull/1188

In most cases, you most likely used the default value anyways. You can replace IdentityCookieOptions with IdentityConstants. If you had customized this value, you may need to find another way to flow your custom scheme names into the appropriate SignInManager calls (and anywhere else auth scheme is used).

Examples:

// old
IdentityCookieOptions.ApplicationScheme
IdentityCookieOptions.ApplicationCookieAuthenticationScheme 
// new
IdentityConstants.ApplicationScheme

// old
IdentityCookieOptions.ExternalScheme 
IdentityCookieOptions.ExternalCookieAuthenticationScheme
//new
IdentityConstants.ExternalScheme

//old
IdentityCookieOptions.TwoFactorRememberMeScheme
IdentityCookieOptions.TwoFactorRememberMeCookieAuthenticationScheme 
//new
IdentityConstants.TwoFactorRememberMeScheme

//old
IdentityCookieOptions.TwoFactorUserIdScheme
IdentityCookieOptions.TwoFactorUserIdCookieAuthenticationScheme 
//new
IdentityConstants.TwoFactorUserIdScheme
like image 57
natemcmaster Avatar answered Oct 28 '22 00:10

natemcmaster