Link to home
Start Free TrialLog in
Avatar of Steve7423
Steve7423Flag for Canada

asked on

ASP.net image not displayed (Relative path of image)

For some reason I can't seem to get the image to display.  In the layout page I have used the following variations for the image.

<img src="/Content/Images/image2.jpg" />
<img src="/../Content/Images/image2.jpg" />
<img src="../Content/Images/image2.jpg" />
<img src="http://" & Request.ServerVariables("MyServer") & Request.ApplicationPath & "/Content/Images/image2.jpg"
<img src="<%= ResolveClientUrl("Content/images/image2.jpg") />

I've even used the absolute path:

<img src="www.websitename.com/Content/Images/image2.jpg" />

Nothing I do seems to display the image.  looking at the folders of C: it's:

C:\inetpub\wwwroot\SiteName\Content\Images\image2.jpg

going through IIS:

ServerName\Sites\Default Web Site\SiteName\Content\Images\image2.jpg
Avatar of becraig
becraig
Flag of United States of America image

Are you having this problem with your published site or do you get this when testing your code.
Avatar of Steve7423

ASKER

With the published site.  everything works fine on my dev machine.  when I publish to the server that's when it fails.
Can you simply right click on the image and copy the source the browser indicates the image is loading from ?
opening the site the image doesn't display.  I Right click the image on the main screen and here's the url path:

http://WebSvr-www1/Content/Images/image2.jpg



this is what I have in the _layout cshtml (view).  As you can see I've tried a couple different methods with no luck.

<img src="/Content/Images/image2.jpg" />

@*<img src="http://" & Request.ServerVariables("WebSvr-www1") & Request.ApplicationPath & "/Content/Images/image2.jpg"

<img src="<%= ResolveClientUrl("Content/images/image2.jpg") />*@
ASKER CERTIFIED SOLUTION
Avatar of Steve7423
Steve7423
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Someone in my office helped me find the solution.