ASP.NET – Image is not showing up

I have placed an image on the master page.

I see the image at design time.

But I don’t see the image at run time.

What can be the problem?

I have tried to place the image on an image box. But it didn’t work either.

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.master.cs" Inherits="Ice_Web_Portal.UI.MasterPage" EnableTheming="true" %>

<!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 runat="server">
    <title>.::ICE Web Portal::.</title>
    <link href="App_Themes/SmokeAndGlass/SmokeAndGlass.css" rel="nofollow noreferrer noopener" rel="stylesheet" type="text/css" />
</head>
<body >
    <form id="form1" runat="server">
        <table style="position: static">
            <tr>
                <td align="left" colspan="2">
                    <asp:Image ID="Image1" runat="server" ImageUrl="~/App_Themes/Banner.JPG" /></td>
                <td>
                </td>
            </tr>
            <tr>
                <td rowspan="2">
                    <div>
                    &nbsp;</div>
                    &nbsp;</td>
                <td style="width: 3px">
                    <asp:LoginView ID="LoginView1" runat="server">
                        <LoggedInTemplate>
                            <table style="width: 204px">
                                <tr>
                                    <td>
                                        Login Status :</td>
                                    <td>
                    <asp:LoginStatus ID="LoginStatus1" runat="server" />
                                    </td>
                                    <td>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Login Name :</td>
                                    <td>
                    <asp:LoginName ID="LoginName1" runat="server" />
                                    </td>
                                    <td>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td>
                                    </td>
                                    <td>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td>
                                    </td>
                                    <td>
                                    </td>
                                </tr>
                            </table>
                        </LoggedInTemplate>
                    </asp:LoginView>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td style="width: 3px">
                    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                    </asp:ContentPlaceHolder>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td style="width: 3px">
                </td>
                <td>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

It sounds like you may have a URL mapping issue of some kind… For the ImageURL property try setting it to “~/Images/MyImage.png”

Rather than storing an image directly in the App_Theme folder, create a folder for images and try to use that instead. The App_Theme directory is handled differently…

Method 2

It sounds like an issue with Relative Paths in Master Pages to me. The solution is the tilda (~) character, which signifies the root folder regardless where the content page resides.

I just tested your code and it worked for me.

Have you tried it using multiple web browsers? (a caching issue perhaps?)
Are you manipulating the image in the code-behind?

Method 3

I think your image files are not accessible on runtime.

Just paste this code in your web.config file and the images will be displayed.

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</configuration>

Method 4

It is a relative path issue, change your stylesheet to:

<link href="~/App_Themes/SmokeAndGlass/SmokeAndGlass.css" rel="nofollow noreferrer noopener" rel="stylesheet" type="text/css" runat="server"/>

Method 5

i had the same problem, it was permissions, just check images that show up in the web form and copy the same permissions to the img not showing up.

Method 6

I know this is a long time question but i happen to see it now, i want to share with you all how i solve mine challenge:

Just replace bellow code in your web.config and put the image path as illustrated

    <location path="Image Path">
    <system.web>
    <authorization>
    <allow user="*"/>
    </authorization>
    </system.web>
    </location>

Hope it help

Method 7

Hmm..seems to be perfectly fine. Did you try to use normal HTML tags like

<img src="<sourceToImage>/App_Themes/Banner.JPG"/>

..just to see whether that works.

Another problem could be the UPPER-case “JPG” extension (although I don’t know whether that really matters).

Check whether your stylesheet does some operations upon images.

Method 8

Simple.

  1. Create a folder Images inside your Project folder.
  2. Place your image, e.g. logo.jpg, inside the Images folder
  3. Back to your project, in your Image properties provide the relative path, i.e your ImageURL, as ~Imageshlogo.jpg.

Your image will then display in the web browser.

Method 9

In IIS 7 when you install the ASP.NET modules, static content is not installed by default. You will need to go into programs and features, then “Turn windows features on or off”.

Under IIS section, drill down into WWW services, Common Http features, and check “Static Content”.

Without that css, images, html, and other non-dynamic content will not show up.

Method 10

I had a similar issue with my VB.NET application using IIS 8.5 on 2012 R2. I has to specifically add my image extensions (.jpg, .png) to ‘Request Filtering’ for my Default site in IIS 8.5.

Method 11

try the below format:

("../App_Themes/Banner.JPG")


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x