2
votes

I changed my website properties in Visual Studio 2010 to "Use local IIS Web Server" instead of the Visual Studio Development Server, and clicked "Create Virtual Directory".

Now my images and styles are not found when I view the website in localhost. The paths in the website are relative. The 404 message says the physical path is "C:\inetpub\wwwroot", which is not the application root. If I copy my image and style folders into "C:\inetpub\wwwroot" then the images appear.

Have I missed some configuration setting to ensure static files come from the application rather than the wwwroot?

3
show how you include image and css files in your View. The proper way is to use Url.Content(...).Igor

3 Answers

3
votes

You'll need to check the application in IIS. The default website defaults to pointing to c:\inetpub\wwwroot by default. If your site is a virtual directory rather than an application in IIS (e.g. http://localhost/yoursite as opposed to http://localhost:6000) and you are referencing your static files using URLs like this: /images/file.jpg, then IIS will be looking in the wwwroot folder for those files.

I would manually create a new website in IIS, pointing at your application's root folder, on a port of your choosing, and then go back to your settings page in Visual Studio and update the port number.

Make sure that your site is a Site in its own right and not a directory hanging off the Default Website. That's more akin to how it will be set up in your live environment anyway.

0
votes

you probably have to publish your site. the VS Dev server runs your code int eh directory that the project is in. to run your code now you probably have to publish to the new locations

0
votes

Old question, but I ran into this.

I double checked my site bindings and the issue that eventually led to this being solved for me was to make a change in my 'host' file.

System32->drivers->etc.

I added my site to this file and it worked like a charm afterwards.