As you knew that master page uses absolute image URL which cause problem to reference an image inside other folder. The problem occurs due to below reasons:
1. Master page is in the root folder
2. Images under another root folder
3. Aspx pages under another root folder
As a result you will get “Image not found” or “Image file path not exist” error.
Scenarios like below will help you to understand the problem:
To set the master page image path to reference an image based on above scenario you may write a code like:
<img alt="" src="Images/logo1.png"/>
Which is actually creating the problem because path will be different for different pages. The solution is simple and you may follow the below code to resolve the error:
<img alt="" src="<%= Page.ResolveUrl("~")%>Images/logo1.png"/>
If you not yet understand the problem then continue to read to run an example. Add a folder named Images also add a folder named CRMM. Now put an image under images folder plus add an aspx page(must include previously defined master page) under CRM folder.
Now modify the Masterpage code like below:
<body> <form runat="server"> <div class="page"> <div class="header"> <div class="title"> <img alt="" width="100px" height="100px" src="<%= Page.ResolveUrl("~")%>Images/logo1.png"/> <h1> My ASP.NET Application </h1> </div> <div class="loginDisplay"> ............................ ............................
Now write a line in frmCustomer Page under CRM folder:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server"> This is Content Page..... </asp:Content>
Now run the project. Hope image path problem will be resolved: