views:

28

answers:

0

We have an ASP.NET MVC 1.0 application that we use to host RESTful web services for some clients. These services all return XML that is built from ViewPage files (each client has their own set of custom formatted XML views but they all use the same controllers, models, etc.).

There is a new web service that needs to write its XML to our disk for later import into an external system as well as return that same XML to the caller as a response. Returning the XML is a snap, but I am having trouble getting that rendered page content into a stream I can write to disk/DB before passing it along to the Response object.

I found the BlockRenderer & CapturingResponseFilter in the mvcontrib project, but I am just not finding any examples of how to use it that make sense to me and my problem. All of the examples seem to center on rendering partial views - which may or may not be the same as rendering a full view, but I haven't figured that out yet.

What I have so far is this:

[HandleError]
public class FooController : Controller
{
 public ActionResult MakeBar(string fooNumber)
 {
  // make sure the foo is valid
  var f = dc.FooHelper.GetFoo(fooNumber);
  if (f == null)
   throw new FooNotFoundException(fooNumber);

  var result = new BlockRenderer(HttpContext).Capture(()=> 

 }
}

This is where I get lost ... what exactly happens inside that BlockRenderer.Capture() signature to tell it that what I want is for it to render the current View to a string and then pass that along to normal process?

TIA