I have a feeling this question may have already been answered a hundred times, if so, sorry, but I could not find the solution.
I have just created a brand new MVC application (the default app) and when I run it from within VS2008 (using Cassini) everything works fine whether I am logged-in to the app or not. If I view source, the path to the CSS file is Content/Site.css.
Then I setup a virtual directory in IIS7 (on Windows 7 Ultimate) and when I access the same application via
http://localhost/myapp/ I am immediately forwarded to the account login page and the CSS path is incorrect for some reason (../Content/Site.css), so there is no formatting. If I register a new user for the app and then log-in,
the CSS path is correct (Content/Site.css) and the formatting appears. But as soon as I log off and reload the page, the formatting once again disappears. This seems odd.
I'm thinking there is something simple that I am overlooking. Can somebody give me a clue? Thanks!
This sounds like an authentication issue i.e. before you login you have no permission to access any resource in the site, MVC pages however because they go throught routing are OK so you may need to add somthing like:
Hi, thanks for the replies. I tried your suggestions but kept getting the same results.
After poking around a bit more I found the solution:
In IIS Manager, I had to go to my app, go into Authentication, select Anonymous Authentication, under Actions on the right-hand side click Edit. It was set to use "Specific user: IUSR". I changed it to use "Application pool identity". Now all works fine.
cheers.
Marked as answer by decimal on Aug 02, 2009 07:44 PM
decimal
0 Points
2 Posts
CSS path incorrect when I'm not logged-in to the Default MVC application (IIS7 - Win7)
Aug 02, 2009 09:45 AM|LINK
I have a feeling this question may have already been answered a hundred times, if so, sorry, but I could not find the solution.
I have just created a brand new MVC application (the default app) and when I run it from within VS2008 (using Cassini) everything works fine whether I am logged-in to the app or not. If I view source, the path to the CSS file is Content/Site.css.
Then I setup a virtual directory in IIS7 (on Windows 7 Ultimate) and when I access the same application via http://localhost/myapp/ I am immediately forwarded to the account login page and the CSS path is incorrect for some reason (../Content/Site.css), so there is no formatting. If I register a new user for the app and then log-in, the CSS path is correct (Content/Site.css) and the formatting appears. But as soon as I log off and reload the page, the formatting once again disappears. This seems odd.
I'm thinking there is something simple that I am overlooking. Can somebody give me a clue? Thanks!
lszk
Member
264 Points
84 Posts
Re: CSS path incorrect when I'm not logged-in to the Default MVC application (IIS7 - Win7)
Aug 02, 2009 11:26 AM|LINK
Maybe try with Url.Content() helper.
sjnaughton
All-Star
27391 Points
5485 Posts
MVP
Re: CSS path incorrect when I'm not logged-in to the Default MVC application (IIS7 - Win7)
Aug 02, 2009 01:28 PM|LINK
This sounds like an authentication issue i.e. before you login you have no permission to access any resource in the site, MVC pages however because they go throught routing are OK so you may need to add somthing like:
<location path="Content"> <system.web> <authorization> <allow users="*"/> </authorization> </system.web> </location>Assuming your css is in the default folder ~/Content see http://support.microsoft.com/kb/316871
MVC Authentication
Always seeking an elegant solution.
decimal
0 Points
2 Posts
Re: CSS path incorrect when I'm not logged-in to the Default MVC application (IIS7 - Win7)
Aug 02, 2009 07:44 PM|LINK
Hi, thanks for the replies. I tried your suggestions but kept getting the same results.
After poking around a bit more I found the solution:
In IIS Manager, I had to go to my app, go into Authentication, select Anonymous Authentication, under Actions on the right-hand side click Edit. It was set to use "Specific user: IUSR". I changed it to use "Application pool identity". Now all works fine.
cheers.
mud8541
Member
2 Points
1 Post
Re: CSS path incorrect when I'm not logged-in to the Default MVC application (IIS7 - Win7)
Nov 08, 2012 05:47 PM|LINK
Thanks a million for posting the fix. Good forum etiquette is so rare.