ISAPI Rewriting, Devices and Korean XML
Taking all my TFTP Provisioning Service stuff at my day job today and providing an HTTPS alternative. Seems that some VOIP devices want to make an HTTPS call for their configuration files.
They expect what the manufacturer programmed them to expect, which in this particular case is what one dood referred to jokingly as "Korean XML" - it has no root element!
That's no big deal, I'll do my stuff and send the device whatever it wants, well-formed or not. The big problem is the device is only smart enough to ask for:
https://myserver/myfolder/DEVICEKEYWITHLONGMACADDRESS.XML
Ok, now how the hell am I gonna map that to my:
https://myserver/myfolder/default.aspx?id=DEVICEKEYWITHLONGMACADDRESS
The answer? ISAPI_Rewrite from Helicon. They have a freeware version, and it handles very nice REGEX URL Rewrites at the IIS level (e.g., way before you ever get to ASP.NET) - which was exactly what I needed.
The Rules file for this particular one is elegantly simple:
[ISAPI_Rewrite]
RewriteRule /myweb/(.*)\.xml /myweb/default.aspx\?id=$1 [I]
Boom! Every request for an XML File in that folder comes into my ASP.NET page, with the DEVICEKEY info right on the querystring where I want it, and the device could care less! The device is asking for a physical file; I am assembling that file's contents via a whole bunch of database and rules logic, and putting it on to the Response Ouput stream, and the device is as happy as a Korean Ch'usok dancer.
Recommended!
They expect what the manufacturer programmed them to expect, which in this particular case is what one dood referred to jokingly as "Korean XML" - it has no root element!
That's no big deal, I'll do my stuff and send the device whatever it wants, well-formed or not. The big problem is the device is only smart enough to ask for:
https://myserver/myfolder/DEVICEKEYWITHLONGMACADDRESS.XML
Ok, now how the hell am I gonna map that to my:
https://myserver/myfolder/default.aspx?id=DEVICEKEYWITHLONGMACADDRESS
The answer? ISAPI_Rewrite from Helicon. They have a freeware version, and it handles very nice REGEX URL Rewrites at the IIS level (e.g., way before you ever get to ASP.NET) - which was exactly what I needed.
The Rules file for this particular one is elegantly simple:
[ISAPI_Rewrite]
RewriteRule /myweb/(.*)\.xml /myweb/default.aspx\?id=$1 [I]
Boom! Every request for an XML File in that folder comes into my ASP.NET page, with the DEVICEKEY info right on the querystring where I want it, and the device could care less! The device is asking for a physical file; I am assembling that file's contents via a whole bunch of database and rules logic, and putting it on to the Response Ouput stream, and the device is as happy as a Korean Ch'usok dancer.
Recommended!
Thanks, I've been looking for something like this!
ReplyDelete