T4MVC calling controller methods multiple times?
Posted
by Maslow
on Stack Overflow
See other posts from Stack Overflow
or by Maslow
Published on 2010-04-10T04:11:20Z
Indexed on
2010/04/10
4:23 UTC
Read the original article
Hit count: 339
T4MVC
|asp.net-mvc
I suspected there was some hidden magic somewhere that stopped what looks like actual method calls all over the place in T4MVC. Then I had a view fail to compile, and the stackTrace went into my actual method, not the generated code in T4MVC.
<%=Ajax.ActionLink("Apply", "Apply", new RouteValueDictionary() { { "shortName", item.Shortname } }, new AjaxOptions() { UpdateTargetId = "masterstatus" })%>
<%=Html.ActionLink("Apply",MVC.Alliance.Apply(item.Shortname),new AjaxOptions() { UpdateTargetId = "masterstatus" }) %>
The second method threw an exception on compile because the method Apply
in my controller has an [Authorize]
attribute so that if someone that isn't logged on clicks this, they get redirected to login, then right back to this page. There they can click on apply again, this time being logged in.
And yes I realize one is Ajax.ActionLink
while the other is Html.ActionLink
I did try them both with the T4MVC version.
Is this a fluke or is it actually calling into the real methods and running my database calling code just to generate the views?
© Stack Overflow or respective owner