Referencing issue with Master page (where the content page is in a different folder)

Content page works fine when the master page is in the same folder, but when they are not, the content page will just give you the cross or question mark error image because the URL is relevant to the content page. 

There are several ways to deal with this issue, and I found the following book on google scholar really helpful:

Core Internet Application Development with ASP.NET 2.0

For example, if you have a master page called main.master right under the project ‘ TestProject’ and have a content page ‘content.aspx’ under a folder called ‘Folder’.

Suppose an image on the master page is <img src=”images/logo.gif”>, which stores in a folder calls ‘images’ under master folder.

You can choose to use ~ symbol like this
<asp:Image runat=”server” id=”testImage” ImageUrl=”~/master/images/logo.gif”/>

However this only works for server control.

The second way is to use absolute path like the following:

<img src=”/master/images/logo.gif”>

What I tried is to put almost all image references in the master page to css file (which is not many), and then reference my master page using the absolute path, so that the master page use the absolute path to read the css file, while whatever in css file does not need to be changed. 



Web Service, the beginning

Web service in consists of a file with the .asmx extension, so you’ll have something like this
<%@ WebService language="VB" codebehind="Service1.asmx.vb" class="Service1" %>
Imports System.Web.Services
Public Class Service1
Inherits System.Web.Services.WebService
Public Function HelloWorld(Byval name As String) As String
Return "Hello World " + name
End Function
End Class

To test this, browser http://localhost/WebService1/Service1.asmx and a simple interface with a list of methods show up.

Click on any one, and put in values for all parameters, click ‘Invoke’ to see the result, it’s not as hard as I thought it would be…