I have a MVC4 web application that works fine on Visual Studio 2012, using the local IIS Express Server. When I publish the application to an IIS 8 web server running on Windows 2012, the initial login page displays correctly. However, using remote debugging, I see that when I check the credentials using the following line:
if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
I get the error shown in the figure below:
(source: usf.edu)
maybe something wrong with your Web.config file. Open the file and find the
<runtime></runtime>
tag. modify the version of MVC. For example, MVC 3Make sure it's looking for the correct version of the file. Mine were incorrect, the web.config file was pointing to later versions than what I had in the project.
In the properties I noted the version was 2.0.0.0 so I made it this version in the web.config file
The
System.Web.Helpers.dll
is included in the official Nuget package Microsoft.AspNet.WebPages.Install that and the references should be corrected, and the file should be copied to your bin folder.
I was able to resolve this by downloading the Microsoft Web Platform Installer, searching for MVC and installing the "ASP.NET MVC3 (Visual Studio 2010 ) Released 4/11/2011" package. Close any Visual Studio instance prior to installing.
I had the same problem working with WCF service in IIS 8. Take a look at this solution Deploying ASP.NET, it worked for me.
After adding the correct version of MVC, the reference to Microsoft Web Helper is added but not of System.Web.Helper. Add this manually to your references.