Masterpage and site navigation with sub pages

Posted on 2012-04-01
Last Modified: 2012-04-02
Hi all,

I have a question and I hope somebody can provide some direction on this and help me get through it.

It deals with a site with a master page but there are several pages that use the master but I have a few sub pages (pages in a sub directory) that I am having trouble with.

The main site has a master page and in it I have some fundamental navigation to like "Home" which is an ahref that goes to "default.aspx". But for example I have something like this:

Main site (with the masterpage)
   - Page 1 (which uses the master page)
   - Page 2 (which uses the master page)
   - TestA/TestPage1 (which uses the master page)
   - TestB/TestPage1 (which uses the master page)

Now, if I'm in "Page 1" and I click on the "Home" which is from the MasterPage it goes to the "default.aspx" just fine and everything is good.

If I'm in "Page 2" and I click on the "Home" which is from the MasterPage it works fine as well and goes to the "default.aspx".

However, and this is there the problem is:

If I'm in TestA/TestPage1 and click on the "Home" which is from the MasterPage it fails because there is no "TestA/default.aspx". The "default.aspx" is in the directory above that. Now, if I change the MasterPage to use "../default.aspx" then it will work but the other pages "Page 1" and "Page 2" will not.

If I'm in TestB/TestPage1 and click on the "Home" which is from the MasterPage it fails because there is also no "TestB/default.aspx". The "default.aspx" is in the directory above that. Now, if I change the MasterPage to use "../default.aspx" and the TestA/TestPage1 will work but the other pages "Page 1" and "Page 2" will not.

How do I get the TestA/TestPage1 and TestB/TestPage1 to use the "default.aspx" in the Masterpage for the "default.aspx" in the root?

Also, I want to avoid using the SiteMap functionality, if at all possible.

Any assistance on this would be greatly appreciated.

Question by:davism
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 21

Expert Comment

ID: 37794322
try modifying like this


Author Comment

ID: 37794408
I tried that as well and the same result. It was still trying go to:




Any other ideas or suggestions or anybody else have any?
LVL 21

Expert Comment

ID: 37794426
well that is weird .. I had a sample project and it works for me!

<a href="~/Default.aspx" >Home</a> will redirect to the default.aspx in the root directory of your application. So double check if you have the default.aspx in the root directory!
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 37794474
I know I have the Default.aspx in the root directory because otherwise I couldn't even get to the main site.
LVL 83

Expert Comment

ID: 37795343
I think one option is to redirect to
LVL 16

Accepted Solution

Vikram Singh Saini earned 500 total points
ID: 37796153
Two solutions:

1. Request.Url.GetLeftPart(UriPartial.Authority) and Page.ResolveUrl()

<a href="<%=Request.Url.GetLeftPart(UriPartial.Authority)%><%=Page.ResolveUrl("~/Default.aspx")%>">

Open in new window

2. string.Concat(), Request.Url.Authority and Request.ApplicationPath

 <a href="<%= string.Concat("http://",this.Context.Request.Url.Authority,this.Request.ApplicationPath)%>/Default.aspx">

Open in new window

Note: Please ensure while typing you do not make any typo mistake or don't leave any space.  Just a precaution.

Author Closing Comment

ID: 37798806
That appears to work. I implemented it in my site and all looks good.

I am going to look at this in more depth for a better understanding.

Thanks much and much appreciated!

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
parse string in c# 5 40
SQL Time out only from one specific computer client 15 47
What!!!??? 5 58
Issue in displaying table columns on selection of dropdown 2 25
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question