ASP.Net - How to generate dynamic meta tags?

random

ASP.Net - How to generate dynamic meta tags?

Generate dynamic meta tag content - ASP .Net

Here we will learn how to add meta tags dynamically in asp.net. First of all add the following namespace references:



using System.Web.UI.HtmlControls;

 C# Code: 

protected void Page_Load(object sender, EventArgs e)
        {
            // set page title
            Page.Title = "How to add meta tags dynamically to .aspx page in Asp.net?";

            //Page description
            HtmlMeta pagedesc = new HtmlMeta();
            pagedesc.Name = "Description";
            pagedesc.Content ="Asp.net,C#.net,SQL Server,Web Services,Ajax,JavaScript,JQuery,Gridview articles and examples";
            Header.Controls.Add(pagedesc);

            //page keywords
            HtmlMeta pagekeywords = new HtmlMeta();
            pagekeywords.Name = "keywords";
            pagekeywords.Content = "asp.net,C#.NET,GridView,DropDownList,,JavaScript,JQuery,XML";
            Header.Controls.Add(pagekeywords);
        }

Output:

Right click on your page and select view source in that check for title, description and keywords:

        
seo, dynamically, meta tag, content, web page, asp .net

ASP.Net - How to generate dynamic meta tags? Reviewed by Ravi Kumar on 3:31 PM Rating: 5
All Rights Reserved by Etechpulse © 2012 - 2017

Contact Form

Name

Email *

Message *

Powered by Blogger.