ASP.NET WebForms の "override void Render" に相当する ASP.NET MVC は何ですか? 出力がクライアントに送信される前に、土壇場で処理を行う機会はどこにありますか?
たとえば、これを運用コードでは使用しませんが、WebForms アプリの MasterPage に配置されたときに、サイト全体の<title>
とマークアップをクリーンアップする方法を示します。<head>
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);
}
ASP.NET MVC で最終的なテキスト レンダリングを試すための最良の方法は何ですか?
更新:
Andrew Hare が言及したリンク (チャート) を見ると、View Engine でこれを実行できるように見えます。デフォルトの View Engine の動作方法をボルトで固定したり変更したりできますか、それともすべてを交換する必要がありますか?