[RESOLVED]HttpException When the Action Link of PratialView Called

I hope you to understand what I am asking for
I get Stack When my Main View Called the PartiaView Action In View
thanks for giving me your time !

public class QuestionsController : Controller { private ApplicationDbContext db = new ApplicationDbContext(); // GET: Questions public async Task<PartialViewResult> _GetQsForTest(int testId) { var quizes = db.Quizes.Include(q => q.Test).Where(q=>q.TestId==testId); ViewBag.TestId = testId; return PartialView("_GetQsForTest",await quizes.ToListAsync()); } // GET: Questions/Create [ChildActionOnly()] public PartialViewResult _QuestionForm(int testId) { Quize quize = new Quize() { TestId = testId }; return PartialView("_QuestionForm", quize); } // POST: Questions/Create [HttpPost] [ValidateAntiForgeryToken] public async Task<PartialViewResult> _submit([Bind(Include = "Id,QuestionNumber,Question,choice1,Choice2,choice3,choice4,Answer,TestId")] Quize quize) { if (ModelState.IsValid) { db.Quizes.Add(quize); await db.SaveChangesAsync(); var quizes = db.Quizes.Include(q => q.Test).Where(q => q.TestId == quize.TestId).ToListAsync(); return PartialView("_GetQsForTest",quizes); } ViewBag.TestId = new SelectList(db.Tests, "Id", "Title", quize.TestId); var quizes = db.Quizes.Include(q => q.Test).Where(q => q.TestId == quize.TestId); return PartialView("_GetQsForTest",quizes1.ToListAsync()); } // here my main view //Test/Details @using System.Web; @model ExamPractice2.Models.ExamParcticeModels.Test @{ ViewBag.Title = "Details"; } <h2>Details</h2> <div> <h4>Test</h4> <hr /> <dl class="dl-horizontal"> <dt> Tutor Name </dt> <dd> @Html.DisplayFor(model => model.ApplicationUser.FristName) </dd> <dt> @Html.DisplayNameFor(model => model.Subject.Name) </dt> <dd> @Html.DisplayFor(model => model.Subject.Name) </dd> <dt> @Html.DisplayNameFor(model => model.Title) </dt> <dd> @Html.DisplayFor(model => model.Title) </dd> </dl> </div> <p> @Html.ActionLink("Edit", "Edit", new { id = Model.Id }) | @Html.ActionLink("Back to List", "Index") </p> @Html.Action("_GetQsforTest", "Questions", new { testId =Model.Id}) // my PArtial view // Questions/_GetQsForTests displays list of Questions @model IEnumerable<ExamPractice2.Models.ExamParcticeModels.Quize> <p> @Html.ActionLink("Create New", "Create") </p> <table class="table"> <tr> <th> @Html.DisplayNameFor(model => model.Test.Title) </th> <th> @Html.DisplayNameFor(model => model.QuestionNumber) </th> <th> @Html.DisplayNameFor(model => model.Question) </th> <th> @Html.DisplayNameFor(model => model.choice1) </th> <th> @Html.DisplayNameFor(model => model.Choice2) </th> <th> @Html.DisplayNameFor(model => model.choice3) </th> <th> @Html.DisplayNameFor(model => model.choice4) </th> <th> @Html.DisplayNameFor(model => model.Answer) </th> <th></th> </tr> @foreach (var item in Model) { <tr> <td> @Html.DisplayFor(modelItem => item.Test.Title) </td> <td> @Html.DisplayFor(modelItem => item.QuestionNumber) </td> <td> @Html.DisplayFor(modelItem => item.Question) </td> <td> @Html.DisplayFor(modelItem => item.choice1) </td> <td> @Html.DisplayFor(modelItem => item.Choice2) </td> <td> @Html.DisplayFor(modelItem => item.choice3) </td> <td> @Html.DisplayFor(modelItem => item.choice4) </td> <td> @Html.DisplayFor(modelItem => item.Answer) </td> <td> @Html.ActionLink("Edit", "Edit", new { id=item.Id }) | @Html.ActionLink("Details", "Details", new { id=item.Id }) | @Html.ActionLink("Delete", "Delete", new { id=item.Id }) </td> </tr> } </table> @using(Html.BeginForm("_submit","Questions",FormMethod.Post)){ @Html.AntiForgeryToken() @Html.Action("_QuestionForm","Questions",new { testId =ViewBag.TestId}) } //Questions/_QuestionForm @model ExamPractice2.Models.ExamParcticeModels.Quize <div class="form-horizontal"> <h4>Quize</h4> <hr /> <div class="form-group"> @Html.LabelFor(model => model.QuestionNumber, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.QuestionNumber, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.QuestionNumber, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.Question, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.Question, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Question, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.choice1, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.choice1, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.choice1, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.Choice2, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.Choice2, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Choice2, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.choice3, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.choice3, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.choice3, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.choice4, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.choice4, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.choice4, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.Answer, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.Answer, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Answer, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> <div class="col-md-offset-2 col-md-10"> <input type="submit" value="Create" class="btn btn-default" /> </div> </div> </div> I get stack when it the main view calls @Html.Action("_GetQsforTest", "Questions", new { testId =Model.Id}) Here is the Stack Trace Server Error in '/' Application. HttpServerUtility.Execute blocked while waiting for an asynchronous operation to complete. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: HttpServerUtility.Execute blocked while waiting for an asynchronous operation to complete. Source Error: Line 45: </p> Line 46: Line 47: @Html.Action("_GetQsforTest", "Questions", new { testId =Model.Id}) Source File: d:MyProjectsProMVC5_AdamFreemanExamPractice2ExamPractice2ViewsTestsDetails.cshtml Line: 47 Stack Trace: [InvalidOperationException: HttpServerUtility.Execute blocked while waiting for an asynchronous operation to complete.] System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) +1596 [HttpException (0x80004005): Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'.] System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) +3177611 System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage) +76 System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +28 System.Web.HttpServerUtilityWrapper.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +19 System.Web.Mvc.Html.ChildActionExtensions.ActionHelper(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues, TextWriter textWriter) +977 System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues) +112 System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName, String controllerName, Object routeValues) +90 ASP._Page_Views_Tests_Details_cshtml.Execute() in d:MyProjectsProMVC5_AdamFreemanExamPractice2ExamPractice2ViewsTestsDetails.cshtml:47 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +271 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +121 System.Web.WebPages.StartPage.RunPage() +63 System.Web.WebPages.StartPage.ExecutePageHierarchy() +100 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +131 System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +695 System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +382 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +431 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +39 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +116 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +529 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +106 System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +321 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +185 System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +42 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +133 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40 System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +34 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44 System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +39 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +62 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39 System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39 System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +39 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +40 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38 System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +129 Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34237 <!-- end snippet -->

can u try commenting out. 

@Html.Action("_QuestionForm","Questions",new { testId =ViewBag.TestId})

It’s doesn’t work . I got "System.ArgumentException"

Cry Please Do u have some other suggestion . thanks

ossprologix

@Html.Action("_QuestionForm","Questions",new { testId =ViewBag.TestId})

couple of months of ago we tried using @Html.Action we got the same exception you are getting.

We opted to @Html.Partial instead of Html.Action.

If might wanna try debugging in razor view.

The stack trace said 

SamuelMebrhatu

Source Error:


Line 45: </p>
Line 46:
Line 47: @Html.Action("_GetQsforTest", "Questions", new { testId =Model.Id})

comment out 


SamuelMebrhatu

@Html.Action("_GetQsforTest", "Questions", new { testId =Model.Id})


SamuelMebrhatu

@using(Html.BeginForm("_submit","Questions",FormMethod.Post)){
@Html.AntiForgeryToken()
@Html.Action("_QuestionForm","Questions",new { testId =ViewBag.TestId})
}

Leave a Reply