问题
I'm building an ajax based web application which lets Facebook users who login to the application, enjoy certain advanced options of the application, like saving their settings, etc` (the user doesn't HAVE to login to his facebook account, but it gives him extra privileges).
I'm using the C# Facebook SDK on ASP.NET WebForms platform. The entire application is AJAX based, which means that after the user decides to log in (using Facebook JS API) and reload the page, the entire communication from that point on is ajax based.
I was wondering if there's a way to make those AJAX requests in the same way I would've done it manually through the browser - meaning that all related facebook and current session cookies will be sent in it's headers. I'm asking this since I don't want to create a custom protocol which will identify the user of the ajax request.
Hope what i'm after is clear through this post...
回答1:
This is my app screen shot, it is ajax as in your case and:
- this ajax call is to local ajax(=to same domain)
- it sends cookies for each ajax call and anchor link(done by browser, send stored cookie in browser for each call )
- X-Requested-With field in the request header helps you understand if this is ajax call or not, more information here: How to know if the request is ajax in asp.net in Application_Error()
来源:https://stackoverflow.com/questions/7838617/ajax-based-web-application-mocking-a-real-request-after-facebook-login