What is the ASP.NET MVC equivalent to "override void Render" from ASP.NET WebForms? Where are you opportunities to do some last-minute processing before the output is sent to the client?
For example, I wouldn't use this in production code, but illustrates cleaning up the <title>
and <head>
markup for an entire site when placed in the MasterPage of a WebForms app.
protected override void Render(HtmlTextWriter writer)
{
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
base.Render(htw);
htw.Close();
string h = sw.ToString();
string fhtml = h.Replace("<title>\r\n\t", "\n<title>")
.Replace("\r\n</title>", "</title>")
.Replace("</head>","\n</head>");
// write the new html to the page
writer.Write(fhtml);
}
What is the best approach for playing with the final text rendering in ASP.NET MVC?
UPDATE:
So looking at the link (the chart) that Andrew Hare mentioned it looks you could do this in the View Engine. Can you bolt things onto or alter the way the default View Engine works or do you have to replace the whole thing?