posted on 16 April 2013


ASP.NET application / website redirects to "Account/Login" with forms authentication enabled

TAGS: Asp.Net,Asp.Net 4.5,C#,IIS 7+,Web.config

I recently created a new web site using the Visual Studio 2012 "ASP.NET Empty Web Site" template, added a login.aspx and default.aspx page and then added the required forms authentication settings to the web.config.

<authentication mode="Forms">
  <forms loginUrl="~/login.aspx" name=".BlahBlahBlah" />
  <deny users="?" />

I browsed to the new website and noticed it was giving me a 404 error. When inspecting the URL, I noticed it was redirecting me to "Account/Login". I started looking through all the code and... nothing, no mention of this URL. I restarted every known process remotely linked to IIS and still nothing. Now, from experience I know this URL is included when creating a default MVC application using Visual Studio, so somewhere deep inside I had a feeling this was a Microsoft "gotcha" that was going to cost me at least 3 cups of coffee. Luckily, when I was at cup 2.4536 I noticed this little line in the web.config.

<add key="webpages:Enabled" value="true" />

Commented it out and all of a sudden, the application redirects to "login.aspx" as specified in the web.config... I'll need to investigate a little deeper into exactly what this setting does and how it got there, but figured I'd put this up for now to save someone out there 3 cups of coffee.

Any questions, let me know


Head of Development for Cergis.

Find out more about Gordon here.


John said:

As much as I don't need the excuse to avoid Coffee (I like coffee!), I am intrigued as to what caused this so I look forward to reading more when you've figured it out! Thank you!

add your comment

Email me when other users reply