5

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?

3 Answers 3

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I've seen this before when toyed with SQLite.
3

How about

routes.RouteExistingFiles = true;

in your Global.asax?

5 Comments

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.
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 ;)
I can access the static files in Content as well when using the development server, but not on my deployment to IIS7.
I only develop with IIS7... Did you try this on another machine with IIS7?
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.
1

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.

4 Comments

There's no route for it, it's static content. That URL gets converted into localhost:8080/Content/Site.css.
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?
No, I can't access static content anywhere. Not CSS or folders (I've enabled indexing).
Glad to see you found a solution, you should mark that as the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.