在视图中执行处理程序的子请求时出错

我有一个MVC 4视图,我在其中呈现以下操作

@{ Html.RenderAction("Index", "Logo"); Html.RenderAction("Index", "MainMenu"); } 

我在我的视图上有一个表格,填写并发布到控制器。 在控制器中,我执行一些任务,然后将模型发送回我的视图

 [HttpPost] public ActionResult Index(ManageAdministratorModel manageAdministratorModel) { // I save some of the fields to the database here. return View(manageAdministratorModel); } 

当我被重定向到视图时,我收到以下错误

执行处理程序’System.Web.Mvc.HttpHandlerUtil + ServerExecuteHttpHandlerAsyncWrapper’的子请求时出错。

在这条线上

 Html.RenderAction("Index", "Logo"); 

知道为什么会这样吗?

好的,我发现了这个问题,希望这将有助于将来的某些人。

部分视图的控制器都包含[HttpGet]属性。 例如

 [HttpGet] public ActionResult Index() { } 

我从两个控制器中删除属性

 public ActionResult Index() { } 

现在一切正常。

当我的部分视图中出现代码格式错误时,我刚刚在剃刀中出现此错误。

如果单击“继续”以通过错误,您将在浏览器窗口中看到显示的实际错误消息。

更正局部视图中的错误,它将工作!

更换:

 return View(manageAdministratorModel); 

有:

 return PartialView(manageAdministratorModel); 

否则你可能会以无限循环结束,因为你正在渲染一个试图渲染试图渲染视图的视图的视图,…

此外,您可能需要从子操作中删除[HttpPost]属性。

“仅限儿童行动”的例子是:

  public class FiltersController : Controller { public ActionResult Index() { return View(); } [ChildActionOnly] public ActionResult Departments() { string s = "Mahi and kallu"; return View(s); } } **for this am creating 2 views** 1) Index:    Index   
@Html.Partial("Departments","Filters")
**and for Departments View:** Departments
@Model
the ***childactions*** can be rendered with the help of "Partial" keyword.

我有完全相同的问题,因为我使用属性路由,内部exception错误消息是:

 No matching action was found on controller ''. This can happen when a controller uses RouteAttribute for routing, but no action on that controller matches the request. 

从Html.Action()调用的动作方法中删除[HttpGet]属性,它可以正常工作。 与路由无关。

摆脱布局@{ Layout = null; } 在子视图中。

我有这个问题,可能会发生因为渲染引擎找不到任何视图(对应于acton中给出的名称)我给出了错误的视图名称(我错误地给出了动作名称而不是视图名称)当我使用PartialView()方法返回视图名称和视图模型,我更正了我的视图名称,它工作正常

我有同样的错误。 它开始时我将动作更改为另一个控制器,因此在运行程序时无法在文件夹中找到该视图。 因此,如果将操作移动到另一个控制器,也将视图移动到相应文件夹的控制器

我收到了这个错误,但我的问题不同了。 要查看错误是什么,请在try catch代码中包含您获得错误的行,如下所示:

  try { @Html.RenderAction("Index", "Logo", new {id = Model.id}); } catch (Exception e) { throw; } 

在抛出线处用断点执行它并检查’e’的内部exception。 我的问题是我在控制器上更改了参数名称,忘了在我的View上更改它。

使用try catch更容易获得错误。

我遇到了同样的问题,但我将[HTTPGet]属性放在函数名称上,它对我有用。

 [HttpGet] //for Filter parital view [ChildActionOnly] public ActionResult Filter() { // Your code will come here. } 

这发生在我身上,因为我从不同的地方调用了这个视图。

我想要调用的视图不在某个区域内,因此当从所有区域外调用它时,会调用它

@Html.RenderAction("Index", "Logo");

会毫无问题地工作。

但是当我想从一个区域内的另一个视图调用相同的视图时,我将不得不在调用中添加一些额外的信息以使其显式:

@Html.RenderAction("Index", "Logo", new { area = "" });