No styles / images on asp.Net MVC 2 application

笑着哭i 提交于 2019-12-05 03:37:36

I had the same issue, but I found the reason why it was forcing authentication on the Contents folder.

When a user is not logged in yet, they are classified as Anonymous Authentication. In IIS7 (which is what I am using, guessing it is the same in IIS6) you need to open the authentication window in features view. Then edit the Anonymous Authentication, to use your application pool identity, or the default one, just make sure that user has permissions to read in that folder.

That fixed it for me, hope it works for you.

Alejandro Sánchez Betancourt

Well, I added the IIS_IUSRs to the project directory and found the same problem:
CSS won't load and nothing from the content folder.
But it resolved the Unable to start debugging on the web server problem.
Then, I added the IUSR to the same folder and that fixed the problem. Now, I can see images, css styles and all that stuff.

This is because you are probably using a fixed path on the src, like: ../../Content/Styles/style.css. In MVC you should use the Url helper: Url.Content("~/Content/Styles/style.css").

Using the Url helper you should have no issues.

Been pulling my hair out all night with this one.

On W2K8, MVC2, .NET 4.0, and IIS 7 (using VS 2010)

Made sure that IIS_IUSRS had full rights to the root folder but still no go - css, js, images still not being accessed in rendering the page....

and then .... so simple:

In Features view for the site - defined MIME types for .js, .css, and .jpg - and voila!

Sweet!

p.s. my 1st mvc app - and I think I'm liking it...

Check the properties of your content folders...see if they are not 'copying locally' for some reason.

The folder that your virtual directory is pointing to gave to the user "All" reading properties.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!