IIS5 216493 Issue
From Facebook Developer Wiki
Problem
Facebook sends a POST request to the callback URL to get the inital canvas page. Developers on IIS5 suffer from bug [[1]] whereby POST requests to URLs ending in / (forward slash) returns a 405 error page. You cannot redirect round it as the POST request from facebook does not follow the redirect.
Solution
Modify your web.config file adding a new httpModule inside the <system.web> section
<httpModules> <add type="namespacePath.ClassName" name="ClassName"/> </httpModules>
Create the class at the correct location for the namespace, where ClassName is the name of the class, for example PathRewriter
using System;
using System.Web;
namespace namespacePath {
public class PathRewriter : IHttpModule {
void IHttpModule.Init(HttpApplication context) { context.BeginRequest += RewriteRequest; }
void IHttpModule.Dispose() { }
public void RewriteRequest(object sender, EventArgs args) {
HttpApplication application = (HttpApplication) sender;
string rawURI = application.Request.RawUrl;
if (rawURI == "/") {
rawURI = "/default.aspx";
}
application.Context.RewritePath(rawURI);
}
}
}
- Finally goto Internet Information Services
- Find your website
- right click, properties.
- Click on the Home Directory tab
- then click Configuration
- The Mappings tab should be selected, if not select it.
- Click Add
- Browse
- Find the aspnet_isapi.dll file in the v2.0.50727 framework folder
- Extension = .*
- Verbs = All Verbs
- Script Engine = ticked
- Check that file exists = unticked
- Click the textbox where the executable is, the Ok button should be clickable now (another microsoft bug)
When you run the site now, what happens is that all requests run through this PathMapper class, if the url is the root url it appends default.aspx before it hits IIS proper bypassing the bug.
You can extend this class to have much nicer paths, so that instead of http://apps.facebook.com/appname/Dostuff.aspx you can make http://apps.facebook.com/appname/Dostuff/ resolve the the same location etc etc
