Wednesday, January 28, 2009

IIS7 and url escaping

First off, sorry I'm such a slacker. Posting to this blog hasn't been one of my top priorities. I have a lot of draft posts that I've started or dropped a few thoughts into and never returned to. I'll work on getting through those. Enough of that.

I've been working on a community that's hosted on Community Server off and on for a while now. Recently my primary client upgraded the test environment server over to a new box with a new version of the OS, SQL Server, and IIS. This has caused some problems with some problems here and there but most of those were taken care of easily. One weird one was that the tagging system in Community Server wasn't working quite right anymore. Single token tags such as "foo" would work as expected however multi token tags "foo bar" were no longer working and I was getting a page not found error. After a lot of digging around I discovered the issue:

IIS6 treats "+" and "%20" in a url the same however IIS7 does not. Community Server uses "+" to indicate spaces in their tag url
s. So for a single token tag you have something like:

[url]/tags/foo/default.aspx

and for a multiple you have:

[url]/tags/foo+bar/default.aspx

At the suggestion of a developer I know I tried replacing the "+" w/ "%20" and low and behold it worked fine. The solution to this issue is to allow double url escaping by adding the following to your web config inside of the System.WebServer element:

<security>
    <requestFiltering allowDoubleEscaping="true" />
</security>



Blog Post on Breaking Changes on IIS7:
http://learn.iis.net/page.aspx/381/aspnet-20-breaking-changes-on-iis-70/

Community Server documentation on this issue here:
http://docswiki.communityserver.com/wikis/cs20085docs/configuring-iis7-for-community-server.aspx