Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7442197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:08:21+00:00 2026-05-29T11:08:21+00:00

I been working on a .NET MVC / Azure / SQL Azure / Facebook

  • 0

I been working on a .NET MVC / Azure / SQL Azure / Facebook app using the facebook c# sdk.

Took a while but I seem to have it logging users in, im able to capture the relevant data needed to use the app.

Without going into what the app is , a user goes through a 3 step process , once the user gets to the end of the process I fire off some generated data to twitter api to post a tweet and also generate a shortened url using the Bit.ly api.

I then give the user the option to post to their facebook wall. I can get the app posting with the right data to the users wall ok.

The problem I face is the URL with the id on the end that is suppose to take any person who clicks it to a partial view displaying relevant data to the id on the URL.

URL looks like this http: //apps.facebook.com/myapp/?id=1
I have two public ActionResult Index(string id) , one with a parameter(POST) & one without(GET)

`

[Authorize]
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Index()
{
    ViewData["Message"] = "Welcome to The My App Website!";
    ViewData["id"] = "null";
    try
    {
    var facebookId = long.Parse(User.Identity.Name);
    var user = InMemoryUserStore.Get(facebookId);
    var client = new FacebookClient(user.AccessToken);
    dynamic me = client.Get("me");
    ViewData["accessToken"] = user.AccessToken.ToString();
    ViewData["FirstName"] = me.first_name;
    ViewData["LastName"] = me.last_name;
    ViewData["Email"] = me.email;
    ViewData["uid"] = facebookId.ToString();


   }
   catch (Exception)
   {
   throw;
   }

    return View();

}

`

    [Authorize]
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Index(string id)
    {
        ViewData["Message"] = "Welcome to My App!";
        ViewData["id"] = id;

        try
        {
            var facebookId = long.Parse(User.Identity.Name);
            var user = InMemoryUserStore.Get(facebookId);
            var client = new FacebookClient(user.AccessToken);
            dynamic me = client.Get("me");
            ViewData["accessToken"] = user.AccessToken.ToString();
            ViewData["FirstName"] = me.first_name;
            ViewData["LastName"] = me.last_name;
            ViewData["Email"] = me.email;
            ViewData["uid"] = facebookId.ToString();


        }
        catch (Exception)
        {
           throw;
        }

        return View();
    }

On the index page using JQuery I do this,

‘

$(document).ready(function () {
var str = "@ViewBag.id";

if(str != "null" || str != null){

                $('#imgLoading').css("display", "inline");
                $('#side').css('display', 'none');
                $('#contentDiv').html("");
                $.get('home/GetUniqueView/?id=' + str, function (data6) {

                $('#contentDiv').html(data6);
                $('#imgLoading').css("display", "none");

                });

    }else{


    }

});

The problem is passing parameters to the actionresult from the facebook canvas

This facebook app url
http: //apps.facebook.com/myapp/ << this would be route /Home/Index

maps to something like this
http: //myapp.cloudapp.net/ << this would be route /Home/Index

so im assuming http://apps.facebook.com/myapp/?id=1 maps to http: //myapp.cloudapp.net/?id=1

in my Global.asax page I have

`

  public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

    }

Can anyone help me or advise on passing parameters to MVC Controller Action Results with the Facebook canvas url’s & facebook c# sdk.

Its important for my app to be able to direct users to a specific view/partial view based on passed id.

Am I going about this the right way, can anyone see a flaw in my approach and is their something im missing or not doing.

best regards

Patrick

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:08:22+00:00Added an answer on May 29, 2026 at 11:08 am

    Am I going about this the right way, can anyone see a flaw in my
    approach and is their something im missing or not doing.

    You seem to be attempting to perform an AJAX request from http://apps.facebook.com/myapp to http://myapp.cloudapp.net/ which obviously is impossible due to the same origin policy restriction built-in browsers. It basically prevents you from sending cross domain AJAX requests. Here’s a guide which covers some possible workarounds.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on ASP.NET MVC for a while and loving it so
I'm working on a multi-tenant ASP.NET MVC application. So far we have been using
Last 8 months I have been working in ASP.NET MVC framework but now I
I have been working my way through Scott Guthrie's excellent post on ASP.NET MVC
I have an asp.net MVC app that i am working on and I wrote
I have been working with ASP.NET MVC for a couple of months now and
I have been working through Microsoft's ASP.NET MVC tutorials, ending up at this page
I have an ASP.NET MVC application that I'm working on. I've been developing it
I've been developing a site using ASP.NET MVC, and have decided to use the
i have been working on a new .net MVC site and have integrated some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.