Avoid using batch inline script using <% %> inside any kind of loops in ASP.NET or MVC. I.e combining the .net server-side code with plain html code in a loop is not good for performance. Too much of batch inline scripts especially inside a loop will reduce the performance of the web application. It’s also not a good practice to use too much of server-side code with <% %>.
Example For batch inline script in a loop:
Below is an example of how to avoid batch inline script in the for loop shown above:
Do you have the performance counters to confirm that inline server code is slower than Response.Write() ? AFAIK, Response.Write() will use a buffer to consolidate output, so theoretically it would be faster, but to what extend ? Is it worth it ? If the’re different by order of magnitude, then we should really consider changing the way we generate HTML.
It would be helpful to provide evidence / measurements to prove the concept. Cheers