I am using MVC 4 and the Razor View Engine.
I have a Html.ActionLink("Title", "Action")
call which is called in a foreach-loop with ~200 items and this takes about 550ms to complete. If I replace the ActionLink with a simple string it only takes ~50ms --> the Html.ActionLink needs ~500ms for 200 iterations!
Is there a way to speed this up?
I have 5 of these in my loop so my page needs >3s to render...
Release build and no debug attribute in the web.config does not help.
I combined a few of the tips from the comments to achive a reduction from ~3s to ~250ms for the rendering of the complete page. The biggest changes where:
@{ var link = Html.ActionLink("_USER_", "Edit", new { id = "_ID_" }); }
before the foreach loop and in the loop something like @link.Replace("_ID_", user.UserId.ToString())
(you can't use String.Format, as the Html.ActionLink()
escapes {0}
to %7B0%7D
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With