views:

1189

answers:

4

I've create a web site on my local IIS 7 with my own ASP.Net MVC project on its root.

Everything is working fine except for the static content. Going to http://localhost:8080/Content/Site.css gives me a 404. I can see the folder on IIS Manager.

The content is served fine with the small development server you get when you run the application on Visual Studio 2008. Any ideas what might be wrong?

+1  A: 

Try going to http://localhost:8080/../../Content/Site.css, not sure if your original URL is matching a route.

Not really a programming question though.

Lazarus
There's no route for it, it's static content. That URL gets converted into http://localhost:8080/Content/Site.css.
J. Pablo Fernández
You're right, I hadn't tried it myself. If you move a copy of the css into the root of the site can you load it then?
Lazarus
No, I can't access static content anywhere. Not CSS or folders (I've enabled indexing).
J. Pablo Fernández
Glad to see you found a solution, you should mark that as the answer.
Lazarus
+2  A: 

How about

routes.RouteExistingFiles = true;

in your Global.asax?

chris166
That in Global.asax.cs didn't help. Is it possible that the ASP.Net MVC template is broken is such a way? I was expecting a configuration issue, not a coding issue. Thanks.
J. Pablo Fernández
The default is that all existing files are routed. When I create a new MVC app in Visual Studio, I can access all static files in /Content. You just have to find who changed the default settings and where ;)
chris166
I can access the static files in Content as well when using the development server, but not on my deployment to IIS7.
J. Pablo Fernández
I only develop with IIS7... Did you try this on another machine with IIS7?
chris166
I don't have any other machine with IIS7, and I'm not sure what I did but it started working after doing that and removing this line.
J. Pablo Fernández
+3  A: 

The problem was permissions. Even though when I create the IIS7 web site I told it to access the files as my user (it wouldn't work at all otherwise), for static file it was using the user of the application pool. Giving access to IIS APPPOOL\MyApplication to the folder where my project was fixed the issue.

J. Pablo Fernández
I've seen this before when toyed with SQLite.
Arnis L.
A: 

Hi,

Has anyone come up with a solution to this problem? I am running windows 7 with IIS7 and my project has started suffering from this problem too. I tried publising an unaltered asp.net mvc 2 application and it too could not read any static content.

Vern
Look at the accepted answer.
J. Pablo Fernández