有谁能告诉我为什么要使用NonAction
属性吗?我的意思是说,我有一个表单有几个提交值:更新、删除或插入.由于所有提交按钮都有相同的共同形式,我在控制器内切换提交值,并相应地采取行动.
如下所示:
public ActionResult asd(string submitButton){
switch(submitButton){
case "Insert":
return Insert();
// bla bla bla
}
}
[NonAction]
public ActionResult Insert(){
// some code inside here
return View();
}
再一次,我为什么要使用非动作而不是这样的东西:
public void Insert(){
// some code inside here
}