Images do not load inside the repeater when deploying a web application in IIS

I deployed my asp.net web application after Microsoft Docs (deployment for testing) .

After deploying my application to IIS, there is a problem that the images inside the Repeater control do not load. Although during debugging / development, they load correctly.

Below is my code (Repeater with Image control):

<asp:Repeater ID="rpBanquetList" runat="server">
    <ItemTemplate>
        //... other controls
        <asp:Image ID="imgImagePath" ImageUrl='<%#"Images/"+Eval("imgImagePath") %>'
            runat="server" />
        //... other controls
    </ItemTemplate>
</asp:Repeater>

Windows 7: IIS 8 Community: VS15

+4
source share
2 answers

You may be having problems with relative URLs. You can try something like:

<asp:Repeater ID="rpBanquetList" runat="server">
<ItemTemplate>
    //... other controls
    <asp:Image ID="imgImagePath" ImageUrl='<%#"~/Images/"+Eval("imgImagePath") %>'
        runat="server" />
    //... other controls
</ItemTemplate>

, AppRootDirectory\Images\, , AppRootDirectory, AppRootDirectory\MyWebform\pageWithRepeaterControl.aspx. URL- :

http://hostName/appName/MyWebForm/Images/ + Eval("imgImagePath"). , /Images/ appName.

, , appName URL- . , -, - IIS -.

~ . , , ~/Images/ http://hostName/appName/Images/, AppRootDirectory\Images\ .

-

, .

+4

asp.net html , .

<asp:Repeater ID="rpBanquetList" runat="server">
    <ItemTemplate>
        //... other controls
         <img id ="imgImagePath" src="<%= AbsolutePath %>images/<%#Eval("imgImagePath")%>"/>
        //... other controls
    </ItemTemplate>
</asp:Repeater>

 string absolutePath =  this.Request.Url.Scheme + "://" + this.Request.Url.Host + ":" + this.Request.Url.Port + this.ResolveUrl("~/");
+1

Source: https://habr.com/ru/post/1692880/


All Articles