i, I have the following URL which is successfully handled by an Apache Tomcat application:
http://localhost:8080/ApplicationX/FileY/UpdateDocument(`<add location="somewhere">ContentZ</add>`).xml?VIEW=RAW
For some reason, when I try to handle the same request in IIS with an ASP.NET Http request handler (Class implementing IHttpHandler), I get the 'Bad request' exception and my code is never called. I have applied this patch in the registry (http://support.microsoft.com/kb/826437) to allow the ':' character but it didn't help with regards to the greater and lesser than characters.
Any ways to make this work? Any reasons with it is allowed in Apache but not in IIS?
Cheers.
P.S. I am using IIS 5.1 on a Windows XP workstation with .NET 3.5 SP1.
Replace >
by %3E
and replace <
by %3C
verified and working.
Try using character entities to escape those characters?:
http://localhost:8080/ApplicationX/FileY/UpdateDocument(`<add location="somewhere">ContentZ</add>`).xml?VIEW=RAW
You need to URLencode your URL, if you want to avoid such problems.
String UrlEncode(String value)
{
StringBuilder result = new StringBuilder();
foreach (char symbol in value)
{
if ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~".IndexOf(symbol) != -1) result.Append(symbol);
else result.Append("%u" + String.Format("{0:X4}", (int)symbol));
}
return result.ToString();
}
The above supports unicode, and pretty much everything.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With