Wednesday, December 05, 2007 

Facebook dev, IIS 5.1, and error 405

In the middle of a Facebook application idea of mine. Using the FacebookToolkit to get something together.

It's pretty interesting how Facebook integrates with 3rd party applications. Short version: User accesses "http://apps.facebook.com/<appplication_name>", Facebooks sends your page a POST (you host it wherever you want); Facebook displays the output of your page. Long story: Basic Application Architecture.

You can configure the location of the page Facebook POSTs to - called the Callback Url. I initially had this set to something like: http://www.mycheaphosting.com/Canvas.aspx. The location the Facebook user accesses, i.e. apps.facebook.com/myapplication/ is called the Canvas Page.

Any relative links within your Callback page will become relative to your Canvas page. For example a link to "blah.aspx", will be treated by the browser as a link to "apps.facebook.com/myapplication/blah.aspx". What does Facebook do with a URL like this? It POSTs to the same 'relative' location on your server. Which in my case would be: http://www.mycheaphosting.com/Canvas.aspxblah.aspx. Yuck!

My first thought was: Okay, I can put the logic into a 'default.aspx', and change the Callback URL to: http://www.mycheaphosting.com/.

Have you ever tried to POST to a default document? Under IIS 5.1 - it actually causes a 405 - 'Resource not allowed' error. The best reference on this I could find was in this comment from David Wang's article HOWTO: POST Resources to IIS:

The ability to POST to a DefaultDocument requires IIS6. Prior IIS versions will return "405 Method not Allowed". That is simply a limitation of the IIS Request Processing Pipeline.

The fix: WebDev.WebServer2 - an alternative to the Cassini web server that comes with VS2005. Unlike Cassini this web server can service external requests.

Labels: ,