We are in the process of moving out our MVC4 web application from VS2013 that uses framework 4.0 and multiple other NuGet packages to VS2019. I branched the code and mapped a new location for the conversion.
I've managed to get everything to build. The site uses Forms Authentication. However, when I try to debug the site the IPrincipal is being set to a WidnowsIdentity, (my domain account), which would be needed to run IIS Express. It's like as if IIS Express is just using the windows authentication from the Development Server settings for the logged in user as well.
I have not changed anything with these settings, so both the Anonymous Authentication and Windows Authentication are both Enabled. The Managed Pipeline Mode is Integrated. Yet I never get to the logon page and it completely bypasses and sets the User to my domain
Yet if I open the project VS2013 project it works as it always has. I know that VS2019 makes a .vs folder for the applicationhost.config file. I've messed around with that file and I'm still not able to get this to run.
Update:
To provide a bit more information. I hadn't noticed this before, but while debugging I noticed that for some reason it's trying to go to our accounts controller as it should, but it's looking for an action of Login. We do not have an action called Login, but we do have a GET and POST LogOn.
I've checked the web.config file as well to ensure that it wasn't somehow changed and it's still ~/Account/LogOn. I've searched the code for anything called Login.
I've even tried to change the loginUrl attribute for the forms authentication and it doesn't appear as though it's even reading that.
Posting the cause and fix for anyone else that may run into the problem.
So after countless searches, failed attempts and hours of debugging it all came down to issues, that for whatever reason, didn't rear their ugly heads in VS2013, but did in VS2019.
We moved from MVC3 to MVC4 a few years ago, before we even moved to VS2013, or right around the same time that we did. Based on two posts I finally found on here lead me to my solution.
Issue 1
First had to do with the redirect to the incorrect login page. We called ours LogOn, but it was being redirected to Login.
The fix was adding the following to the appSettings the following:
<add key="loginUrl" value="~/Account/LogOn" />
Here's the link to the post explaining more and for the credit, Post
Issue 2
The other problem I was still running into was that when the default page was initially hit, and even though was being correctly redirected to the LogOn page, was still setting the User to WindowsIdentity
Again the fix was adding the following lines to the appSettings:
<add key="autoFormsAuthentication" value="false" />
<add key="enableSimpleMembership" value="false"/>
Here's the link to that post explaining more and for the credit, Post