Accessing static content of an ASP.Net MVC project

2019-06-23 04:13发布

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条回答
Animai°情兽
2楼-- · 2019-06-23 04:21

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.

查看更多
做个烂人
3楼-- · 2019-06-23 04:26

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.

查看更多
Bombasti
4楼-- · 2019-06-23 04:37

How about

routes.RouteExistingFiles = true;

in your Global.asax?

查看更多
登录 后发表回答