Asp.net mvc 4 执行处理程序的子请求时出错';System.Web.Mvc.HttpHandlerUtil+;ServerExecuteHttpHandlerAsyncWrapper

Asp.net mvc 4 执行处理程序的子请求时出错';System.Web.Mvc.HttpHandlerUtil+;ServerExecuteHttpHandlerAsyncWrapper,asp.net-mvc-4,Asp.net Mvc 4,我使用的是ASP.NET MVC 4,在2个局部视图中有2个插入查询。 在另一个视图中,调用2操作。但是我得到了这个错误 执行处理程序'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'的子请求时出错 错误: @Html.Action(“InsertState”、“Foundation”) 当我继续时,错误不会在我的页面中显示任何错误,并且插入查询工作正常,但此错误会显示在此之前。您的问题不是很清楚。检查异常消

我使用的是ASP.NET MVC 4,在2个局部视图中有2个插入查询。 在另一个视图中,调用2操作。但是我得到了这个错误

执行处理程序'
System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'的子请求时出错
错误:
@Html.Action(“InsertState”、“Foundation”)


当我继续时,错误不会在我的页面中显示任何错误,并且插入查询工作正常,但此错误会显示在此之前。

您的问题不是很清楚。检查异常消息。这可能是由于视图中的某些错误造成的。

即使从数据库中获取值,使用
ViewBag也没有问题。另外,创建一个由所有所需模型组成的视图模型,然后从控制器传递主模型,并在视图中使用此主模型

型号

public class MainModel 
{ 
    public ModelA objModelA {get;set;}
    public ModelB objModelB {get;set;}
    public ModelC objModelC {get;set;}
}
Public ActionResult ActionName()
{
   ViewBag.state=new SelectList()fdgfg); 
    return View(new MainModel());
}
@model MainModel 
@Html.TextBoxFor(x=>x.ModelA.age)
@Html.TextBoxFor(x=>x.ModelA.name)
@Html.Dropdown("state")
控制器

public class MainModel 
{ 
    public ModelA objModelA {get;set;}
    public ModelB objModelB {get;set;}
    public ModelC objModelC {get;set;}
}
Public ActionResult ActionName()
{
   ViewBag.state=new SelectList()fdgfg); 
    return View(new MainModel());
}
@model MainModel 
@Html.TextBoxFor(x=>x.ModelA.age)
@Html.TextBoxFor(x=>x.ModelA.name)
@Html.Dropdown("state")
查看

public class MainModel 
{ 
    public ModelA objModelA {get;set;}
    public ModelB objModelB {get;set;}
    public ModelC objModelC {get;set;}
}
Public ActionResult ActionName()
{
   ViewBag.state=new SelectList()fdgfg); 
    return View(new MainModel());
}
@model MainModel 
@Html.TextBoxFor(x=>x.ModelA.age)
@Html.TextBoxFor(x=>x.ModelA.name)
@Html.Dropdown("state")

如果局部视图中存在错误,也可能出现此错误。我在主视图中使用局部视图时遇到了这种情况。这是我的观点

   <img  id="image54tr" alt="Image De l'Immobilier" src=""   "/>

如果img标记中还有一个引号,并且在尝试编译时,会出现类似的错误。通过删除此引用并使用下面的标签,问题得以解决

    <img  id="image3im" alt="Image De l'Immobilier" src=""   /> 


这意味着当你有这种类型的错误,首先检查您的partialview,查看是否没有错误,然后再寻找其他解决方法

没有错误,除了此和我的查询工作更正并插入我的数据库,但在插入之前显示此错误,当我单击“继续”时,我会正确查看我的页面当出现此预期时,而不是继续单击“查看详细信息”选项并在视图详细信息中查看异常或messageError:执行处理程序'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'的子请求时出错。InnerException中的错误:{传递到字典的模型项的类型为“MeterControl.Models.DomainModels.tblState”,但此字典需要类型为“MeterControl.ViewModels.FoundationCon.LocationViewModel”的模型项。}@mahdisdezfouli那么我认为您的视图本身存在一些错误。请在视图中添加代码,如果可能的话,请使用屏幕截图将异常添加到主模型,如viewmodel?我有4个PartialView,并使用viewmodel处理此部分。在我看来,使用@html.Action(“Partial1”,“Home”)@html.Action(“Partial2”,“Home”)@html.Action(“Partial3”,“Home”)@html.Action(“Partial4”,“Home”)在部分中,我使用viewmodel填充每个部分的下拉列表。主模型是否与viewmodel?类似。将用于下拉列表的viewmodel添加到主模型-是