tags:

views:

26

answers:

1

Hello all.

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).FirstOrDefault();
        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 
    }
+1  A: 

send another parameter called ReturnUrl and redirect to it on success.

Sruly
with this way i need to do it for all my innumerable forms. It should be any other better solution. Maybe in HttpContext class.
berotomanya
You can always redirect to the Request.UrlReferrer but it may not be correct every time. For example if you were redirected via a login page.
Sruly