Latest From My Blog


Introduction:

           Here I will explain how to add meta tags to a web page dynamically in c# .

Description: 

         
            In Previous posts I explained How to create Facebook App Id for website .Now i will explain how to add meta tags dynamically to .aspx page in c#. It will be helpful while sharing dynamic content  on Facebook .

Aspx Page

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
</head>
<body>
<form id="form1" runat="server">
<div>
<b> Meta Tags Example </b>
</div>
</form>
</body>
</html>


C# Code

In the page load event place the below code to add meta tags dynamically by using namespace System.Web.UI.HtmlControls

   protected void Page_Load(object sender, EventArgs e)
    {
        string fbAppID="445363636336363";
        string strTitle="Share title on facebook";
        string strImg1="http://localhost:6025/Demo/image.jpg";
        string strDesc="Description to share on facebook";
             
        HtmlMeta appId = new HtmlMeta();
        appId.Attributes.Add("property", "fb:app_id");
        appId.Content = fbAppID;
        this.Header.Controls.Add(appId);

        HtmlMeta tag = new HtmlMeta();
        tag.Attributes.Add("property", "og:title");
        tag.Content = strTitle;
        this.Header.Controls.Add(tag);

        HtmlMeta tagimg1 = new HtmlMeta();
        tagimg1.Attributes.Add("property", "og:image");
        tagimg1.Content = strImg1;
        this.Header.Controls.Add(tagimg1);
               
        HtmlMeta tagDesc = new HtmlMeta();
        tagDesc.Attributes.Add("property", "og:description");
        tagDesc.Content = strDesc;
        this.Header.Controls.Add(tagDesc);
    }

If you want to see output run above code snippet, after rendering the page Right click on your page and select view source in that check for Facebook app id, description, image and description meta tags that would be like this.


How to add meta tags dynamically to aspx page in c#

Introduction:

                 Here I will explain how to create Facebook  App ID for your website  .

Description: 
         
               There are many reasons why we want to use Facebook apps.By using Facebook app id, we can integrate Facebook plugins  into our website to share or post our custom text or images. Below are the details steps how to create a Facebook app.

Step 1: Go to Facebook Application Page "https://developers.facebook.com" .
Step 2: Hover your mouse on My Apps and click on "Add A New App".




Step 3: Now it  will open a popup and select website.


Step 4: Provide App name and click on "Create New Facebook App ID" button.


Step 5:  Select  category from dropdown list and click on " Create App ID " button.


Step 6: Now click on " Skip Quick Start " button.you will find your apps dashboard.



Step 7: Now click on setting. Click on add platform > select website icon > and add your domain name with "http://". Fill up all details like contact Email, App Domains and Site URL (See below image for reference). Click on save.


Step 8: Now we have to enable live features available to the general public so go to dashboard , so click on status and review and make it yes.



Step 9: That set now you had your Apps Id, Copy it from your apps dashboard, you can use it where you want to use.

How to Create FaceBook App Id For Website

+