简体   繁体   中英

Reading Meta tags dynamically

Can someone please help me trying to figure out how to simply write the meta tags in an asp.net page. The meta tags have been inserted in the page and I just want to loop through them and write the keywords tag. I don't have a probably adding dynamically, just reading.

.

using System.Web.UI.HtmlControls;
// ...
List<HtmlMeta> metas = new List<HtmlMeta>();
foreach (Control c in this.Page.Header.Controls)
    if (c.GetType() == typeof(HtmlMeta))
    {
        HtmlMeta meta = (HtmlMeta)c;
        if (meta.Name == "Keywords")
            meta.Content = "content goes here";
        break;
    }

Edited to make useful to your situation...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM