简体   繁体   中英

Getting error in mvc4

Error:-

Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'.

My Main page View is this

    {
    ViewBag.Title = "Start";
}

<h2>Start</h2>
<script type="text/javascript"> 

    $(document).ready(function () {

        $("#test1").click(function (e) {
            $("#firstpartialview").css("display", "none");
            $("#secondpatialview").css("display", "none");
            $("#firstpartialview").css("display", "block");
        });

        $("#test2").click(function (e) {
            $("#firstpartialview").css("display", "none");
            $("#secondpatialview").css("display", "none");
            $("#secondpatialview").css("display", "block");                
        });
    });
</script>
<a id="test1"></a>
<a id="test2"></a>
<div id="firstpartialview">@Html.Action("FirstView", "Home")   </div>
<div id="secondpatialview">@Html.Action("SecondView", "Home")   </div>

My controller is this:-

public ActionResult Start()
{
    return View();
}

public ActionResult FirstView()
{
    ModelA objA = new ModelA();
    return PartialView(objA);
}

public ActionResult SecondView()
{
    ModelB objB = new ModelB();
    return PartialView(objB);
}

My Partial View is this

_partialA.cshtml
@model demo3.Models.ModelA

@{
    ViewBag.Title = "_partialA";
}

<h2>_partialA</h2>
<div>@Html.EditorFor(m => m.EmployeeId)  </div>
<div>@Html.EditorFor(m => m.EmployeeName) 

and another partial view is this

_partialB.cs.html
@model demo3.Models.ModelB

@{
    ViewBag.Title = "_partialB";
}

<h2>_partialB</h2>
<div>@Html.EditorFor(m => m.Comapny)  </div>
<div>@Html.EditorFor(m => m.FisacalYear)  </div>

Please help me to solve the error..on browser this error is coming

The partial view 'FirstView' was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Home/FirstView.aspx
~/Views/Home/FirstView.ascx
~/Views/Shared/FirstView.aspx
~/Views/Shared/FirstView.ascx
~/Views/Home/FirstView.cshtml
~/Views/Home/FirstView.vbhtml
~/Views/Shared/FirstView.cshtml
~/Views/Shared/FirstView.vbhtml

The error is quite specific. This line is causing your error:

<div id="firstpartialview">@Html.Action("FirstView", "Home")   </div>

It can't find the view FirstView . You need to place the view in one of the locations that the error message tells you or change where the view engine searches for your views.

The error means that mvc is trying to load a file (by default, if you haven't specified the view file name, it checks by Action name which in this case, is FirstView), but it can't find it.

You can specify the view file name in your return statement:

return PartialView(string "View", object model)

This can be used like so (assuming _partialA is your view's cshtml filename):

return PartialView("_partialA", objA);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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