synercoder / FormsAuthentication

Enable ASP.NET Core 2 cookies to read old ASP.NET Forms Authentication cookies
MIT License
74 stars 25 forks source link

Cookie decryption issue Core 3.1 #20

Closed danielarturo closed 4 years ago

danielarturo commented 4 years ago

I have been trying to integrate the component to my solution but it doesnt call the ConvertCookieToTicket method, in the sample project it works fine, but for some reason I cant identify it doesnt work when using my own login app in spite it seems to be configured just like the one you included in your sample, you can find my test proyecto in this link: https://www.dropbox.com/s/j9t1vi3gp9go582/FormsAuthentication-update-netcore-3.rar?dl=0

When running the solution try using this login: http://localhost:58499/

Any clue of what could be missing or wrong, thank you very much for your time and help

synercoder commented 4 years ago

Don't ask why (was too long ago when I molded the code for the last time), by comparing the setcookie & Presupuestos web.config files and the power of elimination... I present you:

<httpRuntime targetFramework="4.6.1" requestValidationMode="2.0" maxRequestLength="2097151" />
<authentication mode="Forms">
<forms loginUrl="/RHweb_MVC/Seguridad/Login/" protection="All" enableCrossAppRedirects="true" defaultUrl="/RHweb_MVC/" name=".geracauth" timeout="120" path="/" />
</authentication>

You had commented the entire forms line. So the name of the cookie was no longer set. And when the targetframework is missing somehow the correct cookie is also not set. By making those 2 changes (uncommenting the <forms /> & adding targetFramework="4.6.1") Your app will also work for setting the cookie.

synercoder commented 4 years ago

Please reopen if it still won't work.