Asp.Net Mvc重定向问题?

时间:2010-08-30 13:27:26

标签: c# asp.net-mvc

我的故事是:我在单独的视图中有几个表单,用于发布描述信息以进行编辑。每个描述都属于不同的地方。所以我也在我的表单中发送refTypeId信息来决定哪个描述属于哪里。到目前为止还好。但我想返回编辑描述视图,其中编辑描述后发送表单。因此,我需要知道我刚刚在EditDescription操作中编辑的表单来自何处。我的EditDescription操作方法代码如下:

[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 个答案:

答案 0 :(得分:1)

发送另一个名为ReturnUrl的参数,并在成功时重定向到该参数。