HTML.ActionLink method

前端 未结 10 1633
刺人心
刺人心 2020-11-22 11:07

Let\'s say I have a class

public class ItemController:Controller
{
    public ActionResult Login(int id)
    {
        return View(\"Hi\", id);
    }
}
         


        
10条回答
  •  爱一瞬间的悲伤
    2020-11-22 11:30

    I think that Joseph flipped controller and action. First comes the action then the controller. This is somewhat strange, but the way the signature looks.

    Just to clarify things, this is the version that works (adaption of Joseph's example):

    Html.ActionLink(article.Title, 
        "Login",  // <-- ActionMethod
        "Item",   // <-- Controller Name
        new { id = article.ArticleID }, // <-- Route arguments.
        null  // <-- htmlArguments .. which are none
        )
    

提交回复
热议问题