开发者

IIS 6: How to handle a space (%20) after .aspx

Occasionally, my IIS 6 server will receive a request which contains a space after ".aspx", like: http://www.foo.com/mypage.aspx%20?param=value

The "%20" immediately following ".aspx" causes the server to result in a "404 Page Not Found".开发者_如何学编程

Is there a way to configure IIS to accept ".aspx%20" and process the page as if the "%20" didn't exist?

I looked at the "Home Directory" / "Configuration" in the properties of the site in IIS Manager and I added an entry for ".aspx%20" but that didn't work. Any other suggestions are appreciated.


+1 for the custom HttpModule (as Frédéric Hamidi suggested). It's a clean, modular solution and may help you rewrite other URLS, should you need to do so.

Your OnBeginRequest (referring to the link Frédéric provided) might look more or less like this:

private void OnBeginRequest(object sender, EventArgs e)
{
   HttpContext context = ((HttpApplication)sender).Context;
   string url = context.Request.RawUrl;
   context.RewritePath(url.Replace(".aspx%20",".aspx"), false);
}


You might want to consider writing an HTTP module to remove the trailing space from the URL.


Override the 404 page in your web.config and handle the situation you described in code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜