Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
356 views
in Technique[技术] by (71.8m points)

c# - 通过后面的代码向我的SEO页面添加CANONICAL标签?(Adding the CANONICAL tag to my page for SEO through code behind?)

I am using ASP.NET with MasterPages.

(我正在将ASP.NET与MasterPages一起使用。)

Thus i cant just place this link in my pages that reference my MasterPage.

(因此,我不能仅将此链接放在引用我的MasterPage的页面中。)

<link rel="canonical" href="http://www.erate.co.za/" />

I need to place this link in though my Page Load of each one of my pages.

(我需要通过每个页面的页面加载来放置此链接。)

How would i do this through code?

(我将如何通过代码做到这一点?)

I am using VB.NET but C# will also help me in the right direction.

(我正在使用VB.NET,但C#也会在正确的方向上为我提供帮助。)

This is how i did it for my DESCRIPTION tag in my code behind.

(这就是我在后面的代码中为我的DESCRIPTION标记执行的操作。)

    Dim tag As HtmlMeta = New HtmlMeta()
    tag.Name = "description"
    tag.Content = "Find or rate any company in South Africa for FREE and rate them"
    Header.Controls.Add(tag)

Thanks in advance!

(提前致谢!)

  ask by Etienne translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is what i had to do..................

(这就是我要做的......)

    Dim seoTag As HtmlLink = New HtmlLink()
    seoTag.Attributes.Add("rel", "canonical")
    seoTag.Href = "http://www.erate.co.za/"
    Header.Controls.Add(seoTag)

More information Here

(更多信息在这里)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...