- Absolute URL path - src=”http://www.contoso.com/MyApplication/Images/SampleImage.jpg“
- Site Root Relative Path - src=”/Images/SampleImage.jpg”
- Relative path resolved against current page - src=”Images/SampleImage.jpg”
- Relative path resolved as a peer of the current page path - src=”../Images/SampleImage.jpg”
- Site Root Relative Path - ImageUrl=”~/Images/SampleImage.jpg”
ASP.NET includes the Web application root operator (~), which you can use when specifying a path in server controls. ASP.NET resolves the ~ operator to the root of the current application. You can use the ~ operator in conjunction with folders to specify a path that is based on the current root. You can use the ~ operator in any path-related property in server controls. The ~ operator is recognized only for server controls and in server code. You cannot use the ~ operator for client elements.
MapPath
The MapPath method returns the complete physical path for a virtual path that you pass to the method. For example, the following code returns the file path for the root of your Web site:
1 | Dim rootPath As String = Server.MapPath("~") |