Can anybody please tell me why should I use the NonAction
attribute? I mean say I have a form with several submit values: Update, Delete or Insert. Since all the submit buttons have the same form in common I'm switching the submit value inside the controller and act accordingly.
Like this:
public ActionResult asd(string submitButton){
switch(submitButton){
case "Insert":
return Insert();
// bla bla bla
}
}
[NonAction]
public ActionResult Insert(){
// some code inside here
return View();
}
Once again, why should I use NonAction instead of something like this:
public void Insert(){
// some code inside here
}
ChildActionOnly/NonAction
attributes, i.e. their purpose, which was a means to have a "mini MVC" cycle within the main request's MVC cycle. Example would be a view that needs to render/embed a bit more complex partial view. So, rather than calling a<partial>
directly, one can call aNonAction/ChildActionOnly
decorated controller action method usingHtml.RenderAction()
, to perform that "mini MVC" cycle which returns the html markup of a rendered partial view. – Ives