views:

466

answers:

2

Is there a way for a Http Handler to pass a request back up the pipeline to IIS 6 and let it handle the request?

For example, if I have a Http Handler set for verb="(wildcard)" path="(wildcard).txt"

I have a file called myunformated.txt, I would like IIS 6 to send it to the user if it doesn't have querystring params attached.

Any Ideas?

+1  A: 

Why not just: Response.TransmitFile? - note that unlike Response.WriteFile this one won't load the whole file.

You might want to avoid it entirely, and have the link point to a different filename. This way you get all the stuff you wanted from IIS - particularly resuming download.

eglasius
What about things like last-modified directive?
Elijah Glover
you could return that as a header, but I see why you want to avoid it (there are other important stuff that iis can do) ... how about avoiding it entirely by using a different filename ;)
eglasius
+2  A: 

The answer to your question is no. That's what the integrated pipeline of IIS7 acheives but its not available on IIS6.

In this specific case using context.Response.TransmitFile will do the trick although you should consider setting the Response content type, charset and cache control headers, something like:-

HttpResponse Response = context.Response

Response.ContentType = "text/plain";
Response.CharSet = "Windows-1252";
Response.AddFileDependency(filePath);

// Set additional properties to enable caching.
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetValidUntilExpires(true);
Response.TransmitFile(filePath);

This pretty much duplicates what IIS static content handler would be doing.

AnthonyWJones
If the point of .TransmitFile is to write the file directly to the output stream and avoid buffering it to memory, isn't caching the result at odds with that goal?
John
@John: No. Whilst caching will use memory its only using memory that can be easily be spared. Items will drop from the cache the serverside cache if there is need for the memory elsewhere. Transmission is not delayed until the all the content is loaded in memory.
AnthonyWJones