Solved

ASP.net images not displaying

Posted on 2008-10-25
14
900 Views
Last Modified: 2013-12-25
Hello All

I am testing some local ASP.net pages, I have never worked with it before as I am a PHP junkie but I thought I  would play around with it.

I have created a new site in Dreamweaver on my workstation pc. I have connected successfully to a SQL server database which sits on my Small business server and I have a page which displays a dataset of company employees.

My problem is the images, I have referenced the images correctly, source code looks fine when I view the page in firefox. I thought it must be something i'm doing wrong so I created a new .aspx page and then dragged an image onto the page statically. When I preview this page, the static image also does not appear, is there something glaringly obvious i'm missing here?

Best Regards
Bryn
0
Comment
Question by:brynstar
  • 8
  • 5
14 Comments
 

Author Comment

by:brynstar
ID: 22802156
Hello again

Its actually a problem with images..period. If i create a HTML page and insert an image, when I preview it in localhost nothing appears.

I am using windows XP iis

Strange, never encountered this before
0
 
LVL 51

Expert Comment

by:Ted Bouskill
ID: 22806079
ASP.NET websites have to be configured as a 'web application' which assigns an application pool to the website to run the .NET DLLs.  Right click on the website or folder in IIS then select properties and the 'Home Directory' tab.  On that tab you can "Create" a web application.

As a tip with .NET use standard HTML tags by default and only use ASP.NET server controls when you have to.  Don't add overhead if you don't have to.

Also, don't try to imprint PHP techniques onto .NET.  You'll set yourself up for failure.

Work through the samples on www.asp.net to learn more.  Specifically the QuickStart tutorials.
0
 
LVL 6

Expert Comment

by:AmarIs26
ID: 22807014
With VS 2008 and i think 2005 also you get a development server. So you dont really need IIS to test your pages. IF you ceate a project of type "Website" and it is located on filesystem rather than iis then it will by default run your development server.
Anyways, to correctly reference images, the best way is to start from the root and then find your image.
Even html controls in asp.net can be referenced in code.
So if you are using html image then do the following
<img id="myimage" runat="server" src="~/images/myimage.jpg" alt=""/>
The ~ tilde is important, if your control is runing as a server control then tilde will tell the runtime to assign the root path where the tilde apears.
This way you virtual directory can be anything and your paths will always be valid.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:brynstar
ID: 22810729
Hello

As i stated the images will not work on a standard HTML page when previewing the page via

localhost/site/page.htm

I originally thought the ASP.net pages were not correctly displaying the images however, as per my second comment I stated standard html pages were not displaying images.

In dreamweaver you can see the image the page but when you preview it, nothing appears. This is not a path problem, and nothing to do with ASP.net pages, just images themselves when using localhost.

any ideas?
0
 
LVL 6

Expert Comment

by:AmarIs26
ID: 22810981
I thought it must be something i'm doing wrong so I created a new .aspx page and then dragged an image onto the page statically. When I preview this page, the static image also does not appear, is there something glaringly obvious i'm missing here?

Well your original question mentioned ASPX pages. Anyways, if you are testing it with html pages then you should try the following
localhost/site/page.htm
<img src="images/testimage.jpg" />
this means that in the folder that the "page.htm" is located you must have a folder called images and in the images folder an image called testimage.jpg.
If you have the images folder located in the site folder then you can do this
<img src="../images/testimage.jpg"/>
finally (not advisable) you can always assume your site will be deployed in the same manner so you can use the rooted path
<img src="/site/images/testimage.jpg"/>
0
 

Author Comment

by:brynstar
ID: 22811259
Hello Again

Sorry I should probably explain myself more clearly. I have been Web developing for many years, so I know the image tag!

Let me give you an example of my problem

in Firefox
http://localhost/mysite/mypage.htm - no image
file:///C:/Inetpub/wwwroot/mysite/mypage.htm - images show ok
0
 
LVL 6

Expert Comment

by:AmarIs26
ID: 22811351
Can you post the source code when the image shows and does not show.
0
 

Author Comment

by:brynstar
ID: 22811367
sure

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<img src="pictures/Aaron.linton.gif" alt="" />

</body>
</html>
0
 

Author Comment

by:brynstar
ID: 22811399
sorry, previous code when doesnt show. This is when it does

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<img src="pictures/Aaron.linton.gif" alt="" />

</body>
</html>
0
 
LVL 6

Accepted Solution

by:
AmarIs26 earned 500 total points
ID: 22811675
I did what you have done on my local pc and in all cases the image was showing.
I think it could be a permissions issue. So in IIS if you right click on the virtual directory name, all tasks -> permission wizard and then follow the wizard and setup public site permissions, i believe the image will show up on firefox.
 
0
 

Author Comment

by:brynstar
ID: 22811870
You are a gentleman and a scholar! Thank you very much!
0
 

Author Closing Comment

by:brynstar
ID: 31510266
Thanks again my friend!
0
 
LVL 6

Expert Comment

by:AmarIs26
ID: 22812123
You are welcome, i take it that resetting the permissions worked ;)
0
 

Author Comment

by:brynstar
ID: 22814122
Indeed it did. Thanks again
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question