asp mvc RedirectToAction不能正常工作

时间:2014-12-09 15:45:13

标签: asp.net-mvc-4

我已经检查了其他链接中的解决方案,但nothign似乎对我有用。

我有以下内容;

 [HttpPost]        
    public async Task<ActionResult> UpdateDisclaimers(FinanceConfirmViewModel fcvm)
    {
        if (ModelState.IsValid)
        {
           ... processing all works
            return RedirectToAction("Index", enquiryId );    
        }
     }

   [HttpPost]
    public async Task<ActionResult> Index(int? enquiryId)
    {
     .....
    }

但是当UpdateDisclaimers Action运行并成功时,浏览器返回404

Description: HTTP 404. The resource you are looking for (or one of its dependencies) 
could have been removed, had its name changed, or is temporarily unavailable.  Please 
review the following URL and make sure that it is spelled correctly.

Requested URL: /Recommended

(推荐是控制器。)

我可以通过其他地方的Action Link访问Controler索引,但它可以正常工作。 索引是异步的,所以我按照另一个解决方案的建议制作了UpdateDisclaimers Async。

所以我很难过。有什么想法吗?

编辑:将下面的答案标记为正确。解决方案在评论中

1 个答案:

答案 0 :(得分:0)

你需要

public ActionResult Index(int enquiryId)
{
// Code
}

在同一个控制器上

=&GT;最后的回复:因为POST,

return Index(enquiryId);