MagicalArmchair
MagicalArmchair

Reputation: 911

Remove forms authentication on an MVC 4 website

Background

I started an MVC 4, .Net 4.5 website with a view to using Forms authentication, so chose that template. The brief then changed, and I needed to swap to using Windows Authentication instead. This is rolled out onto a Windows Server 2008 box with IIS8.

The problem

I can't for the life on me turn Forms authentication off. After being authenticated through NTLM successfully, MVC tries to take me to a forms login page. I have tried:

None of this works. The only horrible fudge that has worked (from a fellow stackoverflow post) was to change the below in the web.config - this has some funky side effects though (bouncing back to Home on navigation when the app shouldn't for instance) :

<authentication mode="Windows" >
  <!--<forms loginUrl="~/Account/Login" timeout="2880" />-->
  <forms loginUrl="~/Home" timeout="2880" />
</authentication>

The question

I feel I am missing some blindingly obvious (probably filter related) change I need to make to disable and remove forms auth from the project. Can anyone suggest the steps I need to take to remove in permanently?

Upvotes: 3

Views: 5025

Answers (1)

MagicalArmchair
MagicalArmchair

Reputation: 911

ASP.NET MVC3 and Windows Auth on IIS keeps redirecting to /Account/Login

Check whether you have WebMatrix.Data.dll and/or WebMatrix.WebData.dll deployed in the bin directory of your application. If they are there (and you know you don't use them) then try removing them and accessing a page that requires authentication.

I removed references in the project to WebMatrix, deleted them from the local bin and the remote bin, and the unexpected behaviour stopped.

Upvotes: 6

Related Questions