asp.net mvc - Forwarding ModelState error message while using RedirectToAction -
in post method of controller's function have added modelstateerror
. once added redirect method. in method when return view, want able fetch error message passed post method , add modelstate.
[httppost] [validateantiforgerytoken] public actionresult attendeeavailability(params params) { ... ... if (some statement) { modelstate.addmodelerror(string.empty,resource.message); return redirecttoaction("someaction", new { response.appointmentid, response.attendeeid }); } return redirecttoaction("someaction", "somecontroller"); }
now error added, want retrieve in following function
[httpget] public actionresult attendeeavailability(guid appointmentid,guid attendeeid) { ..... modelstate.addmodelerror()//add message passed post(if any); return view(model); }
any suggestions??
then have use tempdata, or session. add error message , display in view.
//in controller string text = tempdata["text"] string; //in view @viewcontext.tempdata["text"]
Comments
Post a Comment