你什么时候使用这个属性ChildActionOnly?什么是ChildAction在什么情况下你想要使用这个属性来限制一个动作?
谁能告诉我为什么要使用NonAction?我的意思是说我有一个包含多个提交值的表单:Update,Delete或Insert.由于所有提交按钮具有相同的共同形式,因此我在控制器内切换提交值并采取相应措施.
像这样:
public ActionResult asd(string submitButton){
switch(submitButton){
case "Insert":
return Insert();
// bla bla bla
}
}
[NonAction]
public ActionResult Insert(){
// some code inside here
return View();
}
Run Code Online (Sandbox Code Playgroud)
再一次,为什么我应该使用NonAction而不是这样的东西:
public void Insert(){
// some code inside here
}
Run Code Online (Sandbox Code Playgroud)