ASPX links not working?

May 12, 2009 at 7:55 pm

An interesting post on our expression web forums asked how links in an aspx based web sites might not be working. Fortunately i had experienced the same issues with many of the aspx data driven sites i build.

One such site ,a mortgage, insurance and debt advice web site threw up exactly the same issues. For example if i wanted to view information on Cheap Car Insurance, the link would look like this

http://www.firstfinancialdirect.com/cheapcarinsurance/

the trailing slash at the end finished the link but i just happen to have a default.aspx page in the folder cheap car insurance so the link actually looks like this…

http://www.firstfinancialdirect.com/cheapcarinsurance/default.aspx

In the case of an aspx which is driven by a master page, this is an issue to be aware of. In my case my master page was in the root of the web site and i used relative links that simply pointed to default.aspx! Wrong because if you are in a folder like the examples above, the link is simply looking for default.aspx. So no problem with the link then! Well no but it was navigating to the cheap car insurance folder default.aspx page

http://www.firstfinancialdirect.com/cheapcarinsurance/default.aspx

instead of the site default (root) which looks like this…

http://www.firstfinancialdirect.com/default.aspx

In the posters case, the same thing applies except in this case, the folder did not contain a default page so hence the error message – that the default.aspx could not be found.

So the lesson to learn is DONT use relative links and if you do make sure that you use a tilde (~) in front of the relative link example:

~/default.aspx this link looks for the root default.aspx page.

I actually went a different route. I used xml to build the above site and was able to make an absolute link by appending the the site address to the file name in the hyperlinks dialogue.

Hope you find this useful.

Advertisements

Entry filed under: expression web.

Microsoft Security Bulletin I goofed up!


Calendar

May 2009
M T W T F S S
« Dec   Jun »
 123
45678910
11121314151617
18192021222324
25262728293031

Most Recent Posts


%d bloggers like this: