ASP MVC Compile-time includes partial view

I have two different views that make up more than 500 partial views, each of which corresponds to a general partial view. Good design tells me that I should leave a partial view where it is and refer to it from both overlying views to prevent code duplication. Unfortunately, performance suffers - copying a partial view in each of the other two views gives an improvement of 300 ms.

In any case, can I include a partial view in the overlying view, taking advantage of performance, without using the actual Partial () call, while not having to maintain duplicate code? Note. I understand that I could write some kind of VS add-on that would copy the paste code, but I'm looking for other options ...

+2
source share
2 answers

What needs to be done to increase productivity:

  • Use @{Html.RenderPartial("_foo");}instead @Html.Partial("_foo")to enable partial
  • Always benchmark in release mode. Many optimizations and caching are performed by ASP.NET MVC as opposed to Debug mode.

2 , HTML-, HTML. , HTML .

+3

, , , ? , , . - .

0

All Articles