Search code examples
asp.net.netiis-6

Publishing asp.net code to the server...Getting Path Issues via MasterFIle


I trying to publish my app from my own PC to the server "C:\Development\MyApp" Everything works fine on my PC but when I publish the application the server my MasterPage looses all the images for the header... It also has problems with tabs when I click on a tab it tells me that the path is incorrect and that Folder/File does not exist.

Here is my code from the master file I don't see anything out of ordinary that could be causing this issue I hope you do :).

<div id="topContant" 
    style="background-image: url('/App_Themes/Sugar2006/images/Header.jpg')">
     <table cellspacing="0" cellpadding="0" border="0" 
         style="height: 80px; width: 100%;">
     <tr>
        <td height="60"  rowspan="1">
            <img alt="" class="style1" 
            src="/App_Themes/Sugar2006/images/assisted-living-concepts.gif" />
        </td>
        <td align="left" valign="top" nowrap class="style2" style="padding-right: 10px;">
            <asp:Label ID="WelcomeUser" runat="server" Text="Welcome: " ForeColor="White"></asp:Label>
            <br />
            <asp:HyperLink ID="lnkMyAccount" Text="My Account" 
                NavigateUrl="~/Users/MyAccount.aspx" style="color:White" CssClass="myAreaLink" 
                Runat="server" Font-Size="Small" />
                &nbsp;|&nbsp;
            <%
                if (CPDManagement._code.Security.IS_ADMIN) {
                %>
                <asp:HyperLink ID="lnkAdmin" Text="Admin" 
                NavigateUrl="~/Administration/default.aspx" style="color:White" 
                CssClass="myAreaLink" Runat="server" Font-Size="Small" />
                <%

                %>
                &nbsp;|&nbsp;
                <%
                }
            %>
            <asp:HyperLink ID="lnkAbout" Text="About" NavigateUrl="~/Home/About.aspx" 
                style="color:White" CssClass="myAreaLink" Runat="server" Font-Size="Small" />
                <%--<br><%= Application["CONFIG.platform_title"] %>--%>
        </td>
        </tr>
        </table>       

</div>




<div id="navcontainer"                                 
    
    style="border-style: outset; border-width: thin; background-color: #663300; height: 30px; ">                
    <ul id="navlist">
        <li runat ="server" id="Home"> <a id="current" href="/Home/Home.aspx" title="Home"><span>Home</span></a></li>
        <%--<li runat ="server" id="Tab2"> <a href="" title="Tab 2"><span>Tab 2</span></a></li>--%>
    </ul>
</div>
<div>

The its failing to display "App_Themes" and also fails to reference to href="/Home/Home.aspx" when clicked on the Home button. I have tried placing a "~" before the "/" or removing the "~" and "/" and nothing. Any ideas?


Solution

  • In case you need to resolve path in non-server tags, use ResolveUrl:

    <li runat ="server" id="Home"> <a id="current" href='<%= ResolveUrl("~/Home/Home.aspx") %>' title="Home"><span>Home</span></a></li>
    

    Also, if you use theming, for images consider using SkinId with asp:Image. For background images, move declarations to css under theme folder.