Accessing static content of an ASP.Net MVC project

2019-06-23 03:49发布

问题:

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:

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.



回答2:

How about

routes.RouteExistingFiles = true;

in your Global.asax?



回答3:

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.