Y'herd thisun? 

“The main requirement is for commerce to replace politics as the driving force behind space policy”

from Spaceflight Revolution by David Ashford

Global.asax for embedded space urls

TaggedCoding, ASP.Net

Remaking this site to run on IIS... ELMAH quickly reminded me of that IIS issue:  ignoring custom error handling when spaces are in the url.

Mostly these come from those cute little korean/slav/russian php scripties, you know the ones, all the variations of: http://[domain]/page%20/index.php?errors=

IIS and web.config customErrors will take care of most odd url requests.. but embed a space and IIS will burp a smelly, and your web.config customError configuration section won't get called so the client will get a generic "resource not found" error page instead of your nice custom one.  You need to handle it in the olde Global.asax

void Application_Error(object sender, EventArgs e)
Exception exception = Server.GetLastError();
HttpException httpException = exception as HttpException;
if (httpException != null)

Yeah, yeah, it's all coming back now... so many years of leading to too much lazy trust in the high levels :).  So, now let me expose my supreme brain fart.  I added that classic to the global.asax and tested and tested in VS and nearly tore my hair out as every time I stepped to the Server.Transfer and got an "HTTPException was unhandled by user code"

Duh.  When you're F5 debugging a cassini instance in the IDE you'll break on errors.  The code is right, but only CTL-F5 (or releasing in non-debug mode) is going to run it correctly.

FYI: Even though you are handling the issue, ELMAH with thankfuly still grab and log/alert on the error AND the error statusCode will be passed back to the requestor (so they won't get a false positive code of 200... though in this case I think they should get a TRON logic bomb sent back across the wire).

These requests are of course most likely being done by bots, so the prettiness of the returned web page doesn't really matter, but there's always some tester in the crowd who will bug you on it, so there you go!

home     who is smith    contact smith     rss feed π
Since 1997 a place for my stuff, and it if helps you too then all the better