Category Archives: .net

SEO – Change Meta Tags Dynamically in SharePoint or Asp.net – (JavaScript & C#) – Google Crawlers

Google-Crawl-Index-550x331

Meta tags are a great way for webmasters to provide search engines with information about their sites. They can be used to provide information to all sorts of clients, and each system processes.

Meta tags are added to the <head> section of your HTML page and you can add them dynamically use JavaScript when page load or using c#:

The following examples explain how can you add it on your header Page:

1. Use c#

public static void ApplyTagsCSharp(string xtitle, string xkeywords, 
string xdescription, Page page)
        {
            page.Title = xtitle;
            ContentPlaceHolder contentPlaceHolder = 
           (ContentPlaceHolder)page.Master.FindControl("PlaceHolderPageTitle");
            contentPlaceHolder.SetRenderMethodDelegate
            (delegate(System.Web.UI.HtmlTextWriter writer,
            System.Web.UI.Control Container)
            {
                writer.Write(xtitle);
            });

            ////Add Keywords Meta Tag
            HtmlMeta keywords = new HtmlMeta();
            keywords.HttpEquiv = "keywords";
            keywords.Name = "keywords";
            keywords.Content = xkeywords;
            page.Header.Controls.Add(keywords);

            //Add Description Meta Tag
            HtmlMeta description = new HtmlMeta();
            description.HttpEquiv = "description";
            description.Name = "description";
            description.Content = xdescription;
            page.Header.Controls.Add(description);
        }

2. Use JavaScript with ClientScriptManager

public static void ApplyTagsJS(string title, string keywords, 
string description, string author, ClientScriptManager csx, System.Type tp)
        {
            String csname2 = "isTagFunction";
            Type cstype2 = tp;

            if (!csx.IsStartupScriptRegistered(cstype2, csname2))
            {
                StringBuilder cstext2 = new StringBuilder();
                cstext2.Append("");
                if (!string.IsNullOrEmpty(keywords))
                {
                    cstext2.Append("$('meta[name=keywords]').remove();");
                    cstext2.AppendFormat("$('head').append( '');", keywords);
                }
                if (!string.IsNullOrEmpty(description))
                {
                    cstext2.Append("$('meta[name=description]').remove();");
                    cstext2.AppendFormat("$('head').append( '' );", description);
                }
                if (!string.IsNullOrEmpty(title))
                {
                  cstext2.AppendFormat("document.title = \"{0}\"; ", title);
                }
                csx.RegisterStartupScript(cstype2, csname2, cstext2.ToString());
            }
        }

Thanks

New ASP.Net Core 1.0

In 2002… was born ASP.NET … after 15 years we are presenting a new framework ASP.NET 5 and replace ASP.NET 4.6…

ASP.NET 5 is now ASP.NET Core 1.0.

.NET 5 is now .NET Core 1.0.

Entity Framework 7 is now Entity Framework Core 1.0 or EF Core 1.0

.NET Core introduce a new concept multi-platform and open source as you can see on the following image:

net core

for more info about .net core check the following links:

https://github.com/dotnet/core

http://docs.asp.net/en/latest/getting-started/installing-on-linux.html

https://blogs.msdn.microsoft.com/dotnet/2014/12/04/introducing-net-core/

Thanks