Recently a question was asked on forums Post Image on FaceBook Wall using ASP.Net, and then I worked on the ASPSnippets FaceBook API to add functionality to upload photos, pictures or images to FaceBook wall
Note: You can download the latest ASPSnippets.FaceBookAPI.dll clicking the download link below.
          Download DLL file
 
 
Upload Photo Image or Picture to FaceBook using Graph API in ASP.Net


 
Create FaceBook Application and get App Id
You will need to create an application and get an API Key and API Secret. You can refer my article
 
 
HTML Markup
The HTML Markup is simple it consist of an ASP.Net FileUpload control, a Multiline TextBox and a Button.
<asp:FileUpload ID="FileUpload1" runat="server" />
<br />
<br />
<asp:TextBox ID="txtMessage" runat="server" TextMode = "MultiLine"></asp:TextBox>
<hr />
<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick = "UploadPhoto" />
 
 
Namespaces
You will need to import the following namespaces
C#
using ASPSnippets.FaceBookAPI;
 
VB.Net
Imports ASPSnippets.FaceBookAPI
 
 
Upload Photo (Image) to FaceBook Wall
On the click of the button the UploadPhoto event handler is raised which sets the uploaded file and the message in the Session variable and then redirects user to FaceBook site to fetch the Access Code.
The FaceBook site redirects back to the page with the access code and then the File and the Message are posted on to the FaceBook wall using the FaceBookConnect PostFile method.
C#
protected void Page_Load(object sender, EventArgs e)
{
    FaceBookConnect.API_Key = "<API Key>";
    FaceBookConnect.API_Secret = "<API Secret>";
    if (!IsPostBack)
    {
        string code = Request.QueryString["code"];
        if (!string.IsNullOrEmpty(code))
        {
            FaceBookConnect.PostFile(code, "me/photos", (HttpPostedFile)Session["File"], Session["Message"].ToString());
            Session["File"] = null;
            Session["Message"] = null;
        }
    }
}
 
protected void UploadPhoto(object sender, EventArgs e)
{
    Session["File"] = FileUpload1.PostedFile;
    Session["Message"] = txtMessage.Text;
    FaceBookConnect.Authorize("user_photos", Request.Url.AbsoluteUri.Split('?')[0]);
}
 
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    FaceBookConnect.API_Key = "<API Key>"
    FaceBookConnect.API_Secret = "<API Secret>"
    If Not IsPostBack Then
        Dim code As String = Request.QueryString("code")
        If Not String.IsNullOrEmpty(code) Then
            FaceBookConnect.PostFile(code, "me/photos", DirectCast(Session("File"), HttpPostedFile), Session("Message").ToString())
            Session("File") = Nothing
            Session("Message") = Nothing
        End If
    End If
End Sub
 
Protected Sub UploadPhoto(sender As Object, e As EventArgs)
    Session("File") = FileUpload1.PostedFile
    Session("Message") = txtMessage.Text
    FaceBookConnect.Authorize("user_photos", Request.Url.AbsoluteUri.Split("?"c)(0))
End Sub
 
 
Demo
 
 
 
 
Downloads