Chris Herring
Chris Herring

Reputation: 3665

Shared ASP forms authentication fails on same domain

I've got an ASP 4.0 web forms application and an ASP MVC 4.5 application that I need to share the forms authentication between. However while I've confirmed using fiddler that the auth cookie is set in the request to the second app it still redirects to the login page.

I've used the same machine key in each application as explained here. I've also created new projects to test this and they however do work.

Upvotes: 0

Views: 107

Answers (1)

Chris Herring
Chris Herring

Reputation: 3665

The issue was in .NET 4.5 there were cryptographic enhancements which meant that although I had the same machine key specified for each app they were decrypted differently. New ASP 4.5 projects have the targetFramework set to 4.5 using the httpRuntime element (see below) while the second project was using .NET 4.0 as it did not have the targetFramework set.

<httpRuntime targetFramework="4.5" />

So I could have either targeted .NET 4.5 in the second project or, to avoid any errors from the upgrade, I can specify the second project to use the cryptographic enhancements in .NET 4.5 for the machine key while continuing to use .NET 4.0.

<machineKey compatibilityMode="Framework45" />

Upvotes: 2

Related Questions