The quick answer


Don’t forget the ~/ (tilde) before the page name.

The lengthy explanation

Assume that we want to redirect to the default.aspx that’s on the site root:


If we’re on a page that’s also on the root, it will map to: and work correctly.

The problem

The problem comes when we’re not on the site root but insite a child folder.
Lets say we’re on a page that’s insite the /Administration folder, the same line will map to that ofcourse won’t resolve and return a glorious 404: Page Not Found.

The solution

Solving this is easy using the ResolveUrl method:


Where this won’t work

ResolveUrl is only available withing the context of a Page or a UserControl, if you’re, for instance, inside an ASHX this method isn’t available.
In these cases you have to use the followinf line to do the job:


We must include the tilde before the page name to make it a relative path, otherwise this method will throw an exception.