Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

Broken images after publishing website

$
0
0

I am using VWD 2010 Express and I have a webpage project built and it previews fine using the "View in Browser" button, but when I publish the site all the images break.  I must warn you, I just started using VWD, vb, etc. about a month ago.  IOW, I'm still learning things.

The issue is with the path.  I just don't know the best/proper way to fix it.

I am using VWD on my desktop and publishing it to a local domain server.  When I preview the page in VWD, the URL is localhost:port/images/filename.png.  After publishing, it was getting server:port/QC/images/filename.png.  The path should actually be server:port/QC/ScrapView/images/filename.png, as this is where VWD is publishing the images to.  I had to change my code behind to add the "/ScrapView" subfolder so it points to the correct place on the server for the images. (see below)

Here is my code behind for getting the image (it's dependent on a value):

Public Shared Function GetImage(ByVal value As Integer) As String
        If (value = 1) Then
            Return "../ScrapView/Images/chkbox_s.png"
        Else
            Return "../ScrapView/Images/chkbox_s2.png"
        End If
    End Function

I WAS using

    Public Shared Function GetImage(ByVal value As Integer) As String
        If (value = 1) Then
            Return "../Images/chkbox_s.png"
        Else
            Return "../Images/chkbox_s2.png"
        End If
    End Function

because it worked for the local use (preview).  But alas, I need it to work on the server, so I used the first code snippet.  But really, it should be working BOTH locally and on the server.  It would be annoying to have to publish the site to see how each change I make affects the page.  Especially AFTER it goes live.  That would not be acceptable.

Hopefully this is clear, but in case it is not, here is a synapsis:

Current state: Preview of the site locally has broken images.  Publishing it to the server displays images correctly.  It has to do with the code behind and the file structure between local and server paths.  I don't know how to fix this because I assumed that publishing all the files would put them in the correct paths so that the site would work as it does locally.  I guess that's my fault for publishing to a subfolder: server:port/QC/ScrapView.  Still, I expected more seemless publishing...

Would like: to see images in both local previews and server published sites, as is the normal process. :\

Thanks for any insight into this.

Gavin


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>