0

I'm working on a slightly low-level ASP.Net project. One of the things I need to support is properly handling HEAD requests. For the uninitiated, a HEAD request is basically just HTTP headers with no content.

Part of this includes a correct content-length. (Even though ASP.Net thinks that the content-length is 0)

I use this code for setting it:

HttpRequest r; .... 
if(r.Headers.AllKeys.Contains("Content-Length")){
    r.Headers["Content-Length"]=length.ToString();
}else{
    r.AddHeader("Content-Length",length.ToString());
}

This runs fine on mod_mono+Apache and on Mono's implementation of xsp, however, on Microsoft's Cassini dev server, this produces a PlatformNotSupportedException with the text This operation requires IIS integrated pipeline mode.

Are there any known workarounds for this issue?

Earlz
  • 62,085
  • 98
  • 303
  • 499
  • 1
    Does it work in IIS? If so, you could always setup an IIS app and point it to your working environment. – MK_Dev Oct 07 '12 at 00:15
  • I agree with MK_Dev that you should use IIS. Cassini is simply a toy, which is never suitable for "low-level ASP.NET project". – Lex Li Oct 07 '12 at 01:52
  • @LexLi My problem is that this is a library for other developers to use, so I really don't want to force everyone who uses my library to use IIS for development... I think I'll just say HEAD requests don't work with Cassini and call it good. – Earlz Oct 07 '12 at 02:11
  • After the introduction of IIS 7, Microsoft soon released IIS Express to replace Cassini. I think that's a nice move to avoid issues like this. So it is time to dump Cassini. Besides, based on HTTP RFC 2616 section 4.4 and 14.13, your attempt to provide correct Content-Length is useless, as a proper implemented HTTP client should automatically ignore it following section 4.4 rule 1. http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4 – Lex Li Oct 07 '12 at 03:38
  • @LexLi hmmm.. interesting. I haven't seen that portion of the spec. I may have to ask another question to have someone explain that to me a bit more – Earlz Oct 07 '12 at 05:58

0 Answers0