jea*_*nml 5 c# apache asp.net iis http
我,我有以下URL,由Apache Tomcat应用程序成功处理:
http://localhost:8080/ApplicationX/FileY/UpdateDocument(`<add location="somewhere">ContentZ</add>`).xml?VIEW=RAW
Run Code Online (Sandbox Code Playgroud)
出于某种原因,当我尝试在IIS中使用ASP.NET Http请求处理程序(实现IHttpHandler的类)处理相同的请求时,我得到"错误请求"异常,我的代码永远不会被调用.我已在注册表(http://support.microsoft.com/kb/826437)中应用此修补程序以允许":"字符,但它对于大于和小于字符没有帮助.
有什么办法使这项工作?在Apache中允许使用它的任何原因但在IIS中不允许吗?
干杯.
PS我在使用.NET 3.5 SP1的Windows XP工作站上使用IIS 5.1.
尝试使用字符实体来逃避这些字符?:
http://localhost:8080/ApplicationX/FileY/UpdateDocument(`<add location="somewhere">ContentZ</add>`).xml?VIEW=RAW
Run Code Online (Sandbox Code Playgroud)
如果您想避免此类问题,则需要对 URL 进行 URL 编码。
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();
}
Run Code Online (Sandbox Code Playgroud)
上面支持 unicode 以及几乎所有内容。
| 归档时间: |
|
| 查看次数: |
8473 次 |
| 最近记录: |