I have an outdated web form application and am creating a new version of MVC to replace it. Both have to work side by side for some time, and I need one sign for the job. Previously, users logged in through the webforms application, and I was able to successfully set forms authentication so that the MVC application can authenticate through the cookie.
Now the MVC application is completing new login forms, and now users will need to log in. The MVC application uses Identity 2.x and OWIN. At first I tried to set the OWIN cookie according to the settings in the legacy webforms application, but I could not get the webforms application to read the cookie and authenticate the user.
Since then, I decided to install Indentity 2.x and OWIN in a webforms application. I made the settings the same. The validity period is 30 minutes, and the domain is ", and the path is" / ". I see that the cookie is created from the MVC application, but it is not picked up by the webforms application. I continue to receive an access denied message.
app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Active, AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, CookieName = Settings.Default.CookieName, CookiePath = Settings.Default.CookiePath, CookieDomain = Settings.Default.CookieDomain, LoginPath = new PathString(Settings.Default.CookieLoginPath), ReturnUrlParameter = Settings.Default.CookieReturnUrl, ExpireTimeSpan = Settings.Default.CookieExpireTimeSpan, SlidingExpiration = Settings.Default.CookieSlidingExpiration, Provider = new CookieAuthenticationProvider { OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>( validateInterval: TimeSpan.FromMinutes(30), regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)) } });
I left the machine key options (which previously worked for forms authentication) the same. However, I removed form authentication from both configuration files.
Am I misconfigured something or are there more settings needed to share the OWIN cookie between applications with the same machine key?
UPDATE
- Created a new web form application with separate user accounts.
- Added MachineKey
- Changed the configuration of the MVC application with the standard settings (copying a new project)
The new webforms application displays a cookie but will not authenticate the user.
UPDATE See answer below.