ASP.Net: Adding feed auto-discovery & meta tags to the page header

Every now and then, I will post code snippets which others might find useful.  Here is one:

How to add an RSS auto-discovery meta tag to the page header:

 Private Sub AddRSSLink(ByVal title As String, ByVal URL As String)
        Dim link As New HtmlLink
        link.Attributes.Add("type", "application/rss+xml")
        link.Attributes.Add("rel", "alternate")
        link.Attributes.Add("title", title)
        link.Attributes.Add("href", URL)
        Page.Header.Controls.Add(link)
    End Sub

What about meta tags?

Dim hm As New HtmlMeta()
hm.Name = "Description" ' Or Keywords
hm.Content = "Description..."
Page.Header.Controls.Add(hm)

Why not just put this in the .aspx you ask? Check out the tags on this page for the answer.

Leave a Reply