views:

122

answers:

6

When I run the site using the normal debug feature of Visual Studio, a lot of images go broken and formatting seems messed up. However, when I deploy the site, it all seems fine.

What could be the reason? As long as it looks good deployed, is it safe to ignore the formatting issues that come up with using undeployed websites?

Note: I am using same browser for both deployed and undeployed website.

+2  A: 

My guess would be image and CSS paths. Perhaps they are relative? Definitely need more information (code) to give you a solid answer.

EDIT: A good way to troubleshoot this would be to right click on the image while debugging and copy its address. Then right click on the image when deployed and copy its address. Compare the two addresses and you might spot something obvious like a path problem.

Mayo
A: 

I would guess that you have some errors in your image paths. Try checking the resulting HTML with for instance Firebug(which is awesome!) to see if the path is wrong.

l3dx
A: 

Maybe like Mayo say, probably the path.

Are you using ~ before your path ... like ~/_images/myImage.jpg or _images/myImage.jpg.

Cédric Boivin
+2  A: 

What are the exact paths of your deployed and undeployed web sites?

You probably have images and CSS files that are referenced using a path that only works on the undeployed web site.

Try loading the deployed web site while running Fiddler and checking which URLs generate errors.

How exactly are you referencing the images and CSS files in your ASP .Net source?

SLaks
+1  A: 

Reasons are addressed by Mayo - but to answer the other question:

No, it is absolutely not safe to ignore the issues unless you have a very clear understanding of why they arise at which point you may be able to choose to not worry about them (although I'd probably not be particularly happy to have to so do).

There are reasons why it may not be practical but pragmatically I require that we can pull a project from version control, build and run and it more or less should run pretty much as live (there are a few caveats about meeting requirements for installed stuff and any necessary config) - certainly I'd expect the appearence to be right.

Murph
A: 

Most of the time, it happens because the ASP.NET development server start your application as a website and you probably deploying on iis in a virtual directory (as an application). So path beginning with / will not react the same way.

As suggested by Cédric, you can start your url with ~ but only if you're using a server site control (like asp:image) or an img html tag with runat="server".

For CSS, javascript or any regular html, you must make sure that all your resources are relative to the page.

I3dx give a good suggestion using firebug to track the faulty url.

Hope it will help

mberube.Net