Search code examples
c#asp.net-coreminifyasp.net-mvc-partialview

return minified partial view from action


I am currently building an ASP.Net Core 3 MVC application. It is a pretty simple Task, I want to return a partial view, but minified in order to save bandwidth.

My current code looks something like the following:

public async Task<IActionResult> Page()
{
    ...

    return PartialView("_PartialView1", object);
}

I mean yea, I could just replace any kind of \n\r, Tabs and spaces, but for the spaces it would also remove spaces which are actually needed.


Solution

  • So there we are about a month later, since I haven't found any good solution which fits my needs, I went ahead and created a Visual Studio Extension which automatically minfies .cshtml files on save.

    So if you are in the same situation as me, give this extension a shot. The source-code for the extension is available over on GitHub.