Reputation: 1425
I have an MVC 3 application which I have been developing, which uses Forms authentication. In my web.config file the only authentication code I have is:
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
I then use the [Authorize]
tag on each individual controller I need to restrict access to.
I run the system on my development machine (Windows 7), an online demo server (Windows 2003 with IIS6.5) and a local production server (Windows 2008 Web Edition R2 with IIS7.5).
When I access the system on the Win2008 server, I am redirected to the login page as expected, however none of the CSS stylesheets load, and all images are missing (all located in the Content folder). This only occurs on the Win2008 server, on my local dev machine and on the Win2003 machine, the CSS and images load just fine.
There are no restrictions on the Content folder, in fact it even contains its own web.config explicitly allowing access to non-authenticated users. I have also tried adding a line to the main web.config allowing full access to Content.
If I place a .htm file in the Content folder, I can access this in the browser. If I try to access an image or a .css file however, I am immediately redirected to the login page!
I am stumped as to what may be causing this.
Upvotes: 1
Views: 942
Reputation: 1425
As mentioned by Wim, the duplicate thread has the answer (although in the comments to the accepted answer in my case).
The problem is caused by the Authentication settings in IIS Manager.
Select your site, then select Authentication. Ensure both Anonymous Authentication and Forms Authentication are both enabled.
In my case, I also had to change the anonymous user - to do so, right click Anonymous Authentication and select Edit. Change it to Application pool identity.
After this, the images and styles load perfectly!
Upvotes: 1