Dynamic SEO for c# website,How To Set Html Title, Meta Keywords & Meta Description From Asp.Net(C#.Net)

Dynamic SEO for c# website,How To Set Html Title, Meta Keywords & Meta Description From Asp.Net(C#.Net)


Dynamic SEO for C# website.
Task: Put SEO stuff (Title of page, Meta keyword, Meta description) in website using c# code in asp.net website/ web application. Onsite SEO –in Dynamic Website or E-Commerce Website.
Description: Now these day SEO is a very important thing in a Website (Dynamic Website or E-Commerce Website). When we work on SEO for website then we require the setup page title, Meta keyword, Meta description. So we require option for this in admin panel for Content Management System Website.

Here I use a small function for this, you can connect it to database and call on pageload.

C# Code for Dynamic SEO

 public void settitle(string pagetitle, string metakeyword, string metadescription)
    {
        HtmlTitle obj = new HtmlTitle();
        obj.Text = pagetitle;
        Header.Controls.Add(obj);

        //  or title can be set as
        Page.Title = pagetitle;

        HtmlMeta mt = new HtmlMeta();
        mt.Name = "keywords";
        mt.Content = metakeyword;
        Header.Controls.Add(mt);

        HtmlMeta mtd = new HtmlMeta();
        mtd.Name = "description";
        mtd.Content = metadescription;
        Header.Controls.Add(mtd);
    }

Comments

Popular posts from this blog

Bootstrap Modal Popup keep open on PostBack in ASP.Net

Resolved Issue in Asp core 3.0 serializersettings does not exist in AddJsonOptions

.Net most asked interview questions for experienced professionals (C#,Asp WEBFORM,MVC,ASP CORE,WEB API,SQL Server,Java Script,Jquery)