Dealing with malformed http headers

By reeset / On / In Microsoft, Programming

If you have a link checker, you invariably want to just read page headers.  Well, in .NET, they enforce a very strict interpretation of the HTTP header standard.  Unfortunately, a great number of servers (Innovative Interface’s ILS for one), don’t follow the output rules, so .NET’s HTTPWebRequest object will throw a webexception when requesting headers from the server.  Correcting this is fairly easy.  Essentially, you need to build a .config file for your component/application and enter the following configuration data:

< configuration>

< system.net>

< settings>

< httpWebRequest useUnsafeHeaderParsing=”true” />

settings>

system.net>

 

–Terry