ASP.NET and canonical links

rrhandle8
rrhandle8 used Ask the Experts™
on
I have a .net 3.5 web site built with Visual Web Developer 2008.  The SEO person has asked me to add a canoncial link to each page.  Is there someway I can do this with code in the MasterPage.  If not, what would you suggest? VB code please.

Here are some links I have already checked-out.  Unfortunately, the more "checking-out" I am doing, the more "screwed-up" I am getting.

http://www.how-to-asp.net/how-to-canonical-urls-asp-net/
http://guyellisrocks.com/coding/adding-a-canonical-link-element-in-asp-net/
http://www.webcatch.co.uk/blog/index.php/2010/10/21/imrpoving-seo-in-asp-net-applications-by-manipulating-titles-meta-tags-and-canonical-urls/
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Director, Information Systems
Commented:
I put a literal control in the header section of the aspx page, called litCanonical.  In the code behind I do this:
      litCanonical.Text = "<link rel='canonical' href='" & Uri.UriSchemeHttp & Uri.SchemeDelimiter & Request.Url.Authority & "/path/pagename.aspx' />"

You would just need to update the path and pagename to reflect the current page.

Author

Commented:
Thanks paulmacd.
If this goes in the masterpage, isn't there some way to grab the page name with code?

Author

Commented:
Question was abandoned.
Paul MacDonaldDirector, Information Systems

Commented:
Sorry [rrhandle8] - I didn't mean to leave you hanging on this!

Did you find an answer to your question about the page name?  It is/should be possible.

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