从同一控制器中的另一个操作调用一个操作,比如从类中的另一个方法调用一个方法或者是否存在性能问题?
public class MemberInformationController : Controller
{
[HttpGet]
public ActionResult PersonalInfo()
{
return View("VPersonalInfo");
}
[HttpPost]
public ActionResult EditPersonalInfo(VMPersonalInfo InModel)
{
if (_member.ID_Member == 0) return Redirect(Url.Action("Login", "MemberShip"));
if (ModelState.IsValid)
{
Member member = new Member();
member.Address = InModel.Address;
member.Email = InModel.Email;
member.ID_Member = _member.ID_Member;
member.MobilePhone = _member.MobilePhone;
member.PhoneNumber = _member.PhoneNumber;
member.UrgentPhoneNumber = _member.UrgentPhoneNumber;
_blMemberShip.EditMember(member, ref Message);
ViewBag.Message = "Successfully done";
return this.PersonalInfo();
}
else
{
ViewBag.Message = "Error in Operation";
return this.PersonalInfo();
}
}
}
例如在MemberInformationController PersonalInfo中,最好从EditPersonalInfo调用PersonalInfo Action或从EditPersonalInfo返回View(" VPersonalInfo")?
答案 0 :(得分:0)
无论您是从操作中返回 VpersonalINfo 查看还是调用上述操作返回视图,都没有任何区别。
你有这两个选项,它取决于你,并取决于应用程序的业务流程,但它不会在性能上有任何不同。