Click here to Skip to main content
12,703,067 members (29,379 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


6 bookmarked

whats the difference in Page class function ResolveURL vs ResolveClientURL

, 16 Sep 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
The .NET Page class contains two methods ResolveUrl and ResolveClientUrl  which are at first glance looks same.They both took same relative url and returns browser friendly URl.

The .NET Page class contains two methods ResolveUrl and ResolveClientUrl  which are at first glance looks same. They both took same relative URL and returns browser friendly URl. So why 2 function to do the same job? Though their functionality is same but their way of returning client brower relative url makes the huge difference.ResolveClientUrl returns a path relative to the current page which user currently browsing, and ResolveUrl returns a path relative to the site root that is configured as root in IIS. 

Lets Consider this structure:

Now from above example root of the IIS directory is ROOT, and all other directory is under this root. Now from MyAccount->default.aspx tries to access Images->mypic.png. ResolveUrl will do top to bottom parsing to find the resource, on other hand ResolveClientUrl will do bottom up parsing to find the same resource.

Function: Page.ResolveUrl("~/Images/mypic.png") 
Returns: "/Images/mypic.png" 
Function: Page.ResolveClientUrl("~/Images/mypic.png")
Returns: "../Images/mypic.png" 

Difference betwwen this two is very visible if you hoste your web app under a shared hosting under a subdomain. For example you host your MY_SITE app under subdomain, and your physical file path is\www\MY_SITE under IIS directory. So under this you placed your file structure given above. Now for any link if you set


watch out the URL in browser status bar you will see www.example.comwww/MY_SITE/MyAccount/default.aspx, because ResolveUrl will parse from top root domain for this resource, so it took full path from root for that specific resource. On other hand ResolveClientUrl can solve this problem, this will parse from browsers present location to up towards the root so find the specific resource path.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Shahriar Iqbal Chowdhury/Galib
Chief Technology Officer
Bangladesh Bangladesh
I am a Software Engineer and Microsoft .NET technology enthusiast. Professionally I worked on several business domains and on diverse platforms. I love to learn and share new .net technology and my experience I gather in my engineering career. You can find me from here

Personal Site
Personal Blog
FB MS enthusiasts group
About Me

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
prabhu singh15-Feb-13 2:27
memberprabhu singh15-Feb-13 2:27 
GeneralRe: My vote of 5 Pin
Shahriar Iqbal Chowdhury/Galib15-Feb-13 21:54
memberShahriar Iqbal Chowdhury/Galib15-Feb-13 21:54 
GeneralMy vote of 5 Pin
Sk. Tajbir9-Jul-12 5:03
memberSk. Tajbir9-Jul-12 5:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170118.1 | Last Updated 16 Sep 2011
Article Copyright 2011 by Shahriar Iqbal Chowdhury/Galib
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid