I’ve set up my Silverlight WP7 app to use a WebBrowser Control to allow users to log into facebook and grant permissions for further actions. After the user has granted permissions, they are redirected to a web page letting them know permissions have been granted.
The chain is as follows:
App -> opens WebBrowser control at web service #1 -> web service redirects to FB -> Permissions granted -> FB redirects to web service #2 which returns a view.
Web services are both within an externally hosted MVC project.
This all works fine, UNLESS the user is not logged into facebook – instead of taking them to the facebook login page as you would expect, I just get an HTTP 500 internal server error and web service #2 is not hit. If the user is logged in, then everything proceeds as it should.
I’ll also mention this ONLY happens on the WP7 device and does not occur in any browser, including IE9, on my laptop.
EDIT: For clarity’s sake, Web browsers on my laptop were tested by setting a breakpoint before my WebBrowser control was called in Visual Studio, I grabbed the Uri I had built there, and pasted it into Chrome, IE9 etc.
I’m not even sure what direction to look in! Also, I’m sure you guys may need more details to aid you with this question – please let me know what else it is you might need and i’ll do my best to provide it.
This code causes the problem.
This code fixes the problem.
Why?
Because Facebook currently has an issue with the Windows Phone 7 User-Agent value and the display parameter values of “touch” and “wap” when they are present in the same request. So simply sending in an alternate User-Agent header when using a WebBrowser control solves the problem for now.
I hope this helps other Windows Phone 7 developers that encounter the nasty 500 error when interfacing Facebook Graph API.