Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No styles / images on asp.Net MVC 2 application

Greetings

i have a little problem with my ASP MVC application. On my local development server everything works just fine but when i try to publish the application to an IIS 7.0 server it just displays plain pages without any styles / markups / images.

I put all those things in the /Content/ subfolder but when i try to access that folder on the production server it just returns me a 404 not found error.

I set the IIS server up with .Net 4.0 and followed the deployment guide on here: http://www.asp.net/learn/mvc/tutorial-08-cs.aspx

All views / controllers / classes seem to work just fine, the only thing which does not is the content subfolder and i cant see why.

Anyone got a suggestion what i could have overlooked or does anyone know that problem?

like image 657
xenolf Avatar asked Apr 21 '10 18:04

xenolf


3 Answers

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.

like image 142
Connor Ross Avatar answered Oct 12 '22 00:10

Connor Ross


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.

like image 24
Alejandro Sánchez Betancourt Avatar answered Oct 12 '22 01:10

Alejandro Sánchez Betancourt


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.

like image 41
Rodrigo Waltenberg Avatar answered Oct 11 '22 23:10

Rodrigo Waltenberg