ASP.NET MVC Equivalent to "override void Render" from ASP.NET WebForms

What is the ASP.NET MVC equivalent of "override void render" from ASP.NET WebForms? Where can you do the last minute processing before sending the sender to the customer?

For example, I would not use it in production code, but it illustrates the layout clean <title>and <head>for the entire site when placed in MasterPage WebForms applications.

    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 way to play with final text rendering in ASP.NET MVC?

UPDATE:
Therefore, looking at the link (diagram) that Andrew Hare mentioned, it looks like you can do it in the View Engine. Can you point something at or change the default way Engine Engine works, or do you need to replace all of this?

+3
2

, MVC.

"onprerender" . , , , .

, , .

, ..

+4

, , Render(), - <head>. MVC, <head> Masterpage.

, html Master, , ViewData["title"] , , .

0

Source: https://habr.com/ru/post/1702978/


All Articles