Reputation: 23094
Looking at the source, I see that a ViewContext is instantiated inside the ViewResultBase.ExecuteResult() method and is passed a writer.
ViewContext viewContext = new ViewContext(context, this.View, this.ViewData, this.TempData, output);
But when the view is rendered the writer is passed into the View.Render() method and I believe that is on purpose, so that view engines other than the WebForms view engine can render into that writer.
this.View.Render(viewContext, output);
So what is the purpose of the writer that's part of the ViewContext?
Upvotes: 2
Views: 300
Reputation: 24754
So you can grab the output of a view and do whatever you need with it. A good example is using the viewengine to render HTML templated emails.
Upvotes: 2