我的页面加载操作结果和 http 发布操作结果都传入模型。
[Authorize]
public ActionResult StepTwo(PostcodesModel model)
{
return View();
}
[Authorize]
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult StepTwo(PostcodesModel model)
{
return View();
}
因为它们都采用了模型,我可以添加什么来使它们独一无二?
最佳答案
你应该使用 ActionName属性,它表示用于操作名称的属性。如果不存在,则使用方法的名称。
[Authorize]
public ActionResult StepTwo(PostcodesModel model)
{
return View();
}
[ActionName("StepTwo")]
[Authorize]
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult StepTwoPost(PostcodesModel model)
{
return View();
}
关于c# - 如何区分 Action 结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22781695/