Asp.Net Mvc redirection problem?
My story is: I have a couple of forms in separately views that post description info to edit. And every description belongs to different places. So I'm sending also refTypeId info in my forms to decide which description belongs where. So far ok. but I want to return back to edit description view where form was sent from after editing description. So I need to know where form came from that I just edited in my EditDescription action. My EditDescription action method following code:
[Authorize]
[HttpPost]
public ActionResult EditDescription(string descriptionToEdit, int refTypeId)
{
var entity = _entities.Descriptions.Where(e => e.Id == refTypeId).Select(e => e).First开发者_运维知识库OrDefault();
entity.Description = descriptionToEdit;
_entities.SaveChanges();
var Description = _entities.Descriptions.Where(e => e.Id == refTypeId).Select(e => e).FirstOrDefault();
ViewData["Description"] = Description.Description;
TempData["Message"]="Description has been saved";
return (?);// i need to know which view that form was sent from
}
send another parameter called ReturnUrl and redirect to it on success.
精彩评论