Links on masterpage are not working

jazz__man
jazz__man used Ask the Experts™
on
Hi

I have the following links on my web page ...

<ul>
            <li><a href="Home.aspx">Home</a></li>
            <li><a href="ClientApplicationForm.aspx">Enquiry Form</a></li>
        </ul>

The links are on the masterpage and work fine while not on the server however when uploaded they do not work.

Your help would be appreciated.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
What error are u getting? 404, page not found?  Check your file locations.

Author

Commented:
Its a "page not found" error, its losing the correct paths because the contained links are on a masterpage.
HainKurtSr. System Analyst

Commented:
use

<ul>
  <li><a href="~/Home.aspx" runat=server>Home</a></li>
  <li><a href="~/ClientApplicationForm.aspx" runat=server>Enquiry Form</a></li>
</ul>

C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Author

Commented:
HainKurt,

Thanks but no joy.
Commented:
<li><a href="~//Home.aspx" runat=server>Home</a></li>
HainKurtSr. System Analyst

Commented:
"Thanks but no joy" does not explain :)
do you have link?
if not, post the rendered html from my post...
check the links and tell what they should be...
HainKurtSr. System Analyst

Commented:
they work fine on server, and then you upload to where?

Author

Commented:
Hi,

I am using a hosting company for my website.

When debugging on my machine the links which are on the master page work correctly with what I had on my initial post. When I upload the website to my webserver the links are not mapped correctly and I get a "page not found" error because it is looking in the wrong directory.

HainKurtSr. System Analyst

Commented:
so, you can give the link on your hosting company...

what code are you using now, and whet is rendered on the page? and what they should be?

Author

Commented:
runat server worked
HainKurtSr. System Analyst

Commented:
that one suggested @36329918 which includes runat=server

and // or / does not make any difference...

please explain why

<li><a href="~//Home.aspx" runat=server>Home</a></li>

worked but not

<li><a href="~/Home.aspx" runat=server>Home</a></li>

Commented:
Asp string / is an escape char.  You might have also been able to use @ in front of the string to say hey ignore the escape chars.  
HainKurtSr. System Analyst

Commented:
This is aspx code not C# code...

<li><a href="~/Home.aspx" runat=server>Home</a></li>
<li><a href="~//Home.aspx" runat=server>Home</a></li>
<li><a href="~///Home.aspx" runat=server>Home</a></li>
<li><a href="~////Home.aspx" runat=server>Home</a></li>

all give the same result, no matter what code behind file is vb or C# or something else... To me he forgot to add runat=server first, which I suggested, then added and accepted the one you posted... I am not convinced yet :)

Commented:
That's not correct /Home & //Home may possibly be different when talking about file locations.  Which is what we were doing here.  If this link is run at server or not the same file reference is made.   I mostly see this with File I/O.
HainKurtSr. System Analyst

Commented:
russellC, can you reproduce this behaviour, I mean "~/some_page.aspx" and "~//some_page.aspx" behaves differently?

Commented:
here is a link on path examples in C sharp.

http://www.dotnetperls.com/path

if you look your original suggestion did not work either.
HainKurtSr. System Analyst

Commented:
but we are talking about aspx code not C# or C++ code...
I tested it on root and on sub folder with ~\,~\\,~\\\,~\\\\ on aspx pages with both vb & c# code behind pages...
they all give the same result... ~\ is the root, after that each \ goes to root again, which is redundant...

can you show that they run differently with a sample

 
HainKurtSr. System Analyst

Commented:
"if you look your original suggestion did not work either"
I am not sure about this, to me he forgot to add runat=server and just put "~\" after my post then after your post he added runat=server and it worked :) still waiting for users input on this...

Commented:
Yes I have seen this in the past with apache running a simulated IIS server and I believe we just did with this question.
HainKurtSr. System Analyst

Commented:
in our case we dont have any apache server running in a simulated mode or something else... it is not mentioned anywhere, and it is not in the zone list of this post... I am still waiting for this question to reopen and user input for this issue...
HainKurtSr. System Analyst

Commented:
still waiting for a response...
HainKurtSr. System Analyst

Commented:
Actually I am not asking for why

<a href="~/Home.aspx" runat=server>Home</a>

did not work and why

<a href="~//Home.aspx" runat=server>Home</a></li>

worked. If you look at his comment "runat server worked", which I already have it in my post... To me, it looks like he first tried

<a href="~/Home.aspx">Home</a>

which does not work obviously, then after a few post, he added "runat=server" and he said "runat server worked" and accepted the solution... even if thats the case, should not the first post does not deserve any points?

HainKurtSr. System Analyst

Commented:
I see this user is active and still I could not get my answer... I just want to know whether

<a href="~/Home.aspx">Home</a>

worked or did not not work! Based on his comment, he accepted an answer after saying "ruan at worked" which I posted at first place...

I am not asking why "/" did not work and why "//" worked! I just want to know what is the solution and wheteher my post worked or not!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial