Sharing URL on Facebok Using ASP.Net

Introduction

In my previous I told you various ways of sharing a URL on Google+ using ASP.NET.

In this article I will tell you about sharing a URL on Facebok using ASP.NET.

Facebook allows you to share many things, like videos, links, images, text and so on. You can also do it from your application created in .NET, so you can implement this feature in your application and allow users to share something.

Step 1

First of all create an ASP.NET application or use a HTML page in your application.

On this application use an anchor and write the following code:

<body>

    <form id="form1" runat="server">

    <div>

        <a href="http://www.facebook.com/sharer/sharer.php?s=100&p[url]=
http://www.c-sharpcorner.com/conference2014/#Register&p[images]=
&p[title]=&p[summary]=">
Share on Facebook</a>

    </div>

    </form>

</body>

</html>

Here I have passed the URL of MVP Summit to be held in April, you can pass your URL instead of mine.

But I have left "[title]" and "[summary]" as blank, you can pass your own title and your own description of the URL that you want to share, if you are not providing any kind of Image, title or description then Facebook will automatically choose one of the images that are used on that website and will also provide the title and description by it's own.

So, only one thing is necessary in the entire code, the URL that you want to share.

Step 2

Now I will run my application and will see what will happen.

On running the application you will see a link available for sharing the URL:

share on facebook

This Link will navigate you to the Facebook page where you need to provide your Authentication (only if you are not Logged In).

share on facebook

Step 3

On providing the Authentication, you will see the URL that you want to share, also if any message or image is associated with it then that will also be displayed but if nothing else is selected then only the URL will be displayed like this:

share on facebook

Now If you choose to Share this Link then the link will be shared and it will be displayed on your Timeline.

share on facebook

You can see that the image and complete description is provided but you can see in the preceding procedure that I haven't provide any of these things, these things are automatically provided by Facebook.


Similar Articles