2

Does anyone know if it is possible to write to the response stream in OpenRasta rather than returning an object as a response resource? Alternatively, am I able to implement an HTTP handler but still leverage OpenRasta's URL rewriting?

Thanks

Chris

chrism
  • 561
  • 4
  • 14

1 Answers1

1

You can always keep an http handler on the side to do specialized things, but that ties you to asp.net and will prevent your code from being portable on other hosts. If that's something you're ok with, any handler that's registered for a specific route will get executed before openrasta on asp.net.

that said, codecs are the ones writing to the response stream, so provided you have a custom IMediaTypeWriter you can write the resource instance on a stream whichever way you want.

Say for example that you returned an IEnumerable from your handler, as those get deferred executed, you can just start the enumeration of those in your custom codec without any problem.

SerialSeb
  • 6,701
  • 24
  • 28
  • Let me also add that if you return Stream itself, that'll work too :) – SerialSeb Aug 20 '11 at 11:27
  • The property response.Stream is read-only in the codec. It seems that doing a .CopyTo(response.Stream) would load the contents of the stream into memory. Does returning a Stream from the handler (thus bypassing the codec) allow the response to be sent without loading the entire object into memory? – Dave Nichol Apr 06 '12 at 12:40