简体   繁体   English

Asp.Net Mvc重定向问题?

[英]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. 因此,我还将在表单中发送refTypeId信息,以确定哪个描述属于哪里。 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. 因此,我需要知道我刚刚在EditDescription操作中编辑过的表单的来源。 My EditDescription action method following code: 我的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 
    }

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM