title: Passing the signed_request along with the AJAX call to an ActionMethod decorated with CanvasAuthorize
body: <p>This is a follow-up to <a href="https://stackoverflow.com/questions/6057973/ajax-call-does-not-trigger-action-method-when-decorated-with-canvasauthorize">AJAX Call Does Not Trigger Action Method When Decorated With CanvasAuthorize</a> </p>
  
  <p>So I found the following links and it seems that this is a common problem:</p>
  
  <p><a href="http://facebooksdk.codeplex.com/discussions/251878" rel="nofollow noreferrer">http://facebooksdk.codeplex.com/discussions/251878</a></p>
  
  <p><a href="http://facebooksdk.codeplex.com/discussions/250820" rel="nofollow noreferrer">http://facebooksdk.codeplex.com/discussions/250820</a></p>
  
  <p>I tried to follow the advice by prabir but I couldn't get it to work... </p>
  
  <p>Here's my setup:</p>
  
  <p>I have the following snippet in the page where the button that triggers the whole post to facebook is located:</p>
  
  <pre><code>@if (!string.IsNullOrEmpty(Request.Params["signed_request"]))
  {
      &lt;input type="hidden" id="signedReq" value="@Request.Params["signed_request"]" /&gt;
  }
  </code></pre>
  
  <p>And then I have this snippet (inside a script tag inside the same page):</p>
  
  <pre><code>    var signedRequest = $('#signedReq').val();
      $('.facebookIcon').click(function () {
          var thisItem = $(this).parent().parent();
          var msg = thisItem.find('.compItemDescription').text();
          var title = thisItem.find('.compareItemTitle').text();
          var itemLink = thisItem.find('.compareItemTitle').attr('href');
          var img = thisItem.find('img').first().attr('src');
          postOnFacebook(msg, itemLink, img, title, signedRequest);
      });
  </code></pre>
  
  <p>And finally, inside an external js file I have the following function:</p>
  
  <pre><code>/*Facebook post item to wall*/
  function postOnFacebook(msg, itemLink, pic, itemTitle, signedReq) {
      console.log(signedReq);
      var siteUrl = 'http://www.localhost:2732';
      $.ajax({
          url: '/Facebook/PostItem',
          data: {
              'message': msg,
              'link': siteUrl + itemLink,
              'picture': siteUrl + pic,
              'name' : itemTitle,
              'signed_request': signedReq
          },
          type: 'get',
          success: function(data) {
              if(data.result == "success") {
                  alert("item was posted on facebook");
              }
          }
      });
  }
  </code></pre>
  
  <p>But signedReq is always undefined. And I'm not really sure I should be passing the 'signed_request' field inside the data object. Any thoughts?</p>