title: ASP.NET Facebook app session issue with safari
body: <p>Currently I am working on a Facebook app and it's developed by using ASP.NET.</p>
  
  <p>This app works fine with IE(7,8 and 9) FF and Chrome.</p>
  
  <p>The first page is default.aspx and it will handle the authentication then redirect to home.aspx</p>
  
  <p>Now the only issue it has is that Safari doesn't accept cross-domain cookies. I've changed the web.config file and add it  in order to avoid the use of cookies.</p>
  
  <p>After that, the URL comes to 
  <a href="http://www.testdomain.com/(S(gvsc2i45pqvzqm3lv2xoe4zm))/default.aspx" rel="nofollow">http://www.testdomain.com/(S(gvsc2i45pqvzqm3lv2xoe4zm))/default.aspx</a></p>
  
  <p>It just can't be redirect from default.aspx to home.aspx automatically...</p>
  
  <p>Anyone got a clue?</p>
  
  <p>Or, is there anyway that i can deal with Safari with ASP.Net session in Facebook app?</p>
  
  <p>Tons of thanks</p>
  
  <p>PS. The code from default.aspx page</p>
  
  <p>protected void Page_Load(object sender, EventArgs e)
      {
          if (!IsPostBack)
          {
              if (!string.IsNullOrEmpty(Request.Params["signed_request"]))
              {
                  string signed_request = Request.Params["signed_request"];
                  if (!string.IsNullOrEmpty(signed_request))
                  {
                      // split signed request into encoded signature and payload
                      string[] signedRequestParts = signed_request.Split('.');
                      string encodedSignature = signedRequestParts[0];
                      string payload = signedRequestParts[1];</p>
  
  <pre><code>                // decode signature
                  string signature = decodeSignature(encodedSignature);
                  // calculate signature from payload
                  string expectedSignature = hash_hmac(payload, Facebook.FacebookApplication.Current.AppSecret);
  
                  if (signature == expectedSignature)
                  {
                      // signature was not modified
                      Dictionary&lt;string, string&gt; parameters = DecodePayload(payload);
                      if (parameters != null)
                      {
                          string UserId = parameters["user_id"];
                          Session.Add("UserId", _SystemUser.SystemUserId);
                          Session.Add("Username", _SystemUser.Username);
                          Response.Redirect("Home.aspx?user_id=" + UserId);
                      }
                  }
              }
          }
  
          if (!String.IsNullOrEmpty(Request["error_reason"])) // user denied your request to login
          {
              logger.Debug("Error Reason: " + Request["error_reason"]);
              //User denied access
          }
  
          if (String.IsNullOrEmpty(Request["code"])) // request to login
          {
              string url1 = String.Format("https://www.facebook.com/dialog/oauth?client_id={0}&amp;redirect_uri={1}&amp;scope={2}", Facebook.FacebookApplication.Current.AppId, callbackUrl, ext_perms);
              Response.Redirect(url1);
          }
      }
  }
  </code></pre>