Simple 5 Steps to publish on a facebook wall using DotNet C#/ cSharp

There are many Libraries available for C# and Dotnet to publish on facebook.

According to facebook Wiki posting on a wall is very confusing and very difficult to write a program to publish on a wall.

I spent around 2 weeks reading many articles and many documents, Wiki on facebook but in vein and tried many ways and finally I got one workable model. Below are 5 simple steps to publish on a Facebook wall.

Step1: Login to Facebook

First login to Facebook and goto the url then

Click on “+ Set Up New Application” button to start creating the application as shown below.

start application

Provide the application name, click agree for facebook terms and click on “Create Application” button.

Fill in application Name

create app step1

Now Application is created for you. Just copy the Application API Key, Application Secret and Application ID details which will be used to write the application code.

application page

Now goto Canvas link and enter any url.


Next goto Connect URL link and enter the same url.


Then click on Save. That’s it we have created a facebook application with an Iframe.

Now Copy Application API Key, Application Secret and Application ID details which will be used to write the application code.

Now download any of the available libraries on facebook


Microsoft SDK for Facebook Platform, which supports Facebook Connect, FBML and IFrame canvas page applications, and ASP.NET MVC. For issues and discussions about the SDK see the project on Codeplex.

Step2: Generate One Time Session key

How to generate One Time Session key:

Run below URL to get temporary token for the selected user by logging into Facebook.

Note: Please replace “API_KEY” with your application API key from above page.

Then we will get a temporary token key.


generatemylogin info


This is one time token key that we can use to generate a permanent session key. Careful! Don’t try to execute this programs many times

Step3: Generate one time session key

Below is the sample code to generate one time session key.

For example, the full URL for logging in a user could be:,publish_stream,offline_access

If the user is redirected to the URL specified by the next parameter, then Facebook grants your application a session. This session is appended to the URL as a JSON-decodable object of the form:

&session={“session_key”:”SESSIONKEY”, “uid”:USERID, “expires”:0 || UNIXTIME, “secret”:”SESSIONSECRET”}

In continuing with the above example, the redirect for a successful login would be:

If the user grants your application the offline_access extended permission, 0 gets returned for expires and the session never expires unless the user removes the application. In this case, you should store the session key so the user doesn’t have to log in the next time he or she launches your application.

Once the browser has been redirected successfully and you have your session information, you should automatically close the browser window.
Note: The above code will execute only once. We should note down the above session key, This will be used to auto login into the application.

If you don’t save these session key values you should generate other token key to create one time session key.


Giving Permission to your application to publish on facebook wall. To give permission just replace the your API key in below URL and execute in browser.,publish_stream,offline_access

Then you must see the below 3 Screens

If you don’t see the below then your call back URL or Canvas URL must be incorrect, please check again your application settings and execute the URL again.



Then on final page, you will see a success message. That’s it you have given permission for read_stream,publish_stream and offline_access.

Step5: Publishing the message with Image and link on Facebook Wall using cSharp/ C#

Publishing a Post With Image and Action Link in C# using facebook developer toolkit v2

C# Code to create facebook object with onetime session key and publishing the message on Facebook Wall.

public void Post(facebook.API fbAPI, string appLink)
 string response = "publish steven on facebook.",
new attachment() {
name = "I am a good guy !", href = appLink, caption = "{*actor*} Steven Publish on facebook wall",
description = "Helping other people, I became a new good guy.", properties = null,
 media = new List<attachment_media>() { new attachment_media_image()
{ src = "", href = appLink } } },
new List<action_link>() { new action_link() { text = "Become a good guy",
 href = appLink } }, null, 0);

Now you will see the post on wall Great.

published on facebook

So thrilling isn’t we can also publish photos videos on wall.

have a great day

— Steven

Please don’t copy this content to any site. This is fully protected by TheUnical Technologies

Good Visual Studio Tutorials from

Good Visual Studio Tutorials Links.

Happy Reading..

visual studio 2010

visual studio 2010 download

visual studio 2010 release date

microsoft visual studio 2010

visual studio 2010 release

visual studio 2010 screenshots

visual studio 2010 features

visual studio 2010 wiki

visual studio 2010 blog

visual studio 2010 rapidshare

visual studio 2010 review

visual studio 2010 screenshot

visual studio 2010 video

microsoft visual studio 2010 download

visual studio 2010 iso

visual studio 2010 new features

visual studio 2010 preview

what’s new in visual studio 2010

visual studio 2010 mfc

visual studio 2010 msdn

visual studio 2010 requirements

visual studio 2010 wikipedia

visual studio 2010 ctp2

visual studio 2010 news

visual studio 2010 password

visual studio 2010 professional

visual studio 2010 sdk

visual studio 2010 what’s new

visual studio 2010 downloads

visual studio 2010 expired

visual studio 2010 launch

visual studio 2010 trial

visual studio 2010 videos

whats new in visual studio 2010

new features in visual studio 2010

new in visual studio 2010

visual studio 2010 c#

visual studio 2010 demo

visual studio 2010 extensibility

visual studio 2010 ide

visual studio 2010 intellisense

visual studio 2010 launch date

visual studio 2010 multi monitor

visual studio 2010 price

visual studio 2010 screen shots

visual studio 2010 slow

visual studio 2010 tutorial

features of visual studio 2010

release date for visual studio 2010

visual studio 2010 activation

visual studio 2010 forum

visual studio 2010 parallel

buy visual studio 2010

date visual studio 2010

how to install visual studio 2010

install visual studio 2010

installing visual studio 2010

release date of visual studio 2010

visual studio 2010 .net

visual studio 2010 64

visual studio 2010 architecture

visual studio 2010 asp net

visual studio 2010 asp net mvc

visual studio 2010 changes

visual studio 2010 expiration

visual studio 2010 expire

visual studio 2010 extension

visual studio 2010 feedback

visual studio 2010 free

visual studio 2010 installation

visual studio 2010 jquery

visual studio 2010 mef

visual studio 2010 performance

visual studio 2010 released

visual studio 2010 screen

visual studio 2010 ship date

visual studio 2010 timeline

visual studio 2010 training

visual studio 2010 upgrade

visual studio 2010 virtual

visual studio 2010 web

visual studio 2010 windows xp

welcome to visual studio 2010

when visual studio 2010

Create a Virtual Directory in IIS 7.0


A virtual directory is a directory name, used in an address, which corresponds to a physical directory on the server. You can add a virtual directory that will include directory content in a site or an application without having to move the content physically into that site or application directory.

To add a virtual directory

You can perform this procedure by using the user interface (UI), by running Appcmd.exe commands in a command-line window, by editing configuration files directly, or by writing WMI scripts.
User Interface
To use the UI


Open IIS Manager. For information about opening IIS Manager, see IIS 7.0: Open IIS Manager.

In the Connections pane, expand the Sites node in the tree, and then click to select the site in which you want to create a virtual directory.

In the Actions pane, click View Virtual Directories.

On the Virtual Directories page, in the Actions pane, click Add Virtual Directory.

In the Add Virtual Directory dialog box, type a name in the Alias box. This alias is used to access the content from a URL.

In the Physical path box, type the physical path of the content folder, or click Browse to navigate through the file system to find the folder.

Optionally, click Connect as to specify credentials that have permission to access the physical path. If you do not use specific credentials, select the Application user (pass-thru authentication) option in the Connect As dialog box.

Optionally, click Test Settings to verify the settings that you specified for the virtual directory.

Click OK.

Command Line

To add a virtual directory to the root application in a site, use the following syntax:

appcmd add vdir / /path:string /physicalPath:string

The variable app.namestring is the site name and the / following the name specifies that the virtual directory should be added to the root application of the site. The variable pathstring is the virtual path of the virtual directory, such as /photos, and physicalPathstring is the physical path of the virtual directory’s content in the file system.

For example, to add a virtual directory named photos with a physical location of c:images to the root application in a site named contoso, type the following at the command prompt, and then press ENTER:

appcmd add vdir / /path:/photos /physicalPath:c:images

To add a virtual directory to an application other than a site’s root application, type the name of the application after / in app.namestring. For example, to add the same virtual directory used in the previous example to an application named marketing in a site named contoso, type the following at the command prompt, and then press ENTER.