T4MVC not generating an action

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 14:43 UTC
Read the original article Hit count: 386

Filed under:
|

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.

        [Authorize]
    public string Apply(string shortName)
    {
        if (shortName.IsNullOrEmpty())
            return "Failed alliance name was not transmitted";
        if (Request.IsAuthenticated == false || User == null || User.Identity == null)
            return "Apply authentication failed";
        Models.Persistence.AlliancePersistance.Apply(User.Identity.Name, shortName);
        return "Applied";
    }

So this method isn't generating in the template after all.

<%=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.

© Stack Overflow or respective owner

Related posts about T4MVC

Related posts about asp.net-mvc