Dear All , I met with an issue I need to show my partial view listing as data table for that I have set up everything I needed and I am able to see the datatable in partial view as well ,
THE PROBLEM IS THAT main main view render twice with two times menu and main content in which i am calling partial view and the code never ends I debug the code and it comes in index controller method for infinit number of times below is my code.
My main view code is below
@model WEB.ViewModels.MyVm
@using WEB.Classes

Tuhin PaulRank #7 · 71.9K reputationPosted Aug 11, 2024, 11:29 AM EDT
HTML @await Html.PartialAsync("~/Views/details/studentdetails.cshtml") --------------- JavaScript function LoadPartialView() { $.ajax({ url: '@Url.Action("GetStudentDetails", "studentdetails")', type:'GET', success: function (data) { $('#PartialViewContainer').html(data); $('#tblApplications').DataTable(); } }); } ----------------------------- [HttpGet] public IActionResult GetStudentDetails() { // Return the partial view with the student details return PartialView("~/Views/details/studentdetails.cshtml", model); }Tuhin PaulRank #7 · 71.9K reputationPosted Aug 11, 2024, 11:28 AM EDT
The issue you're facing is due to the recursive loading of the partial view in the main view.
In your main view, you're calling
@await Html.PartialAsync("~/Views/details/studentdetails.cshtml")which loads the partial view.In the partial view, you're calling
LoadPartialView()function which makes an AJAX call to theIndexaction in thestudentdetailscontroller. TheIndexaction returns the main view again, which in turn loads the partial view again, and so on. This creates an infinite loop where the main view and partial view keep loading each other. To fix this, you should remove the recursive loading of the partial view.Mark TaborRank #914 · 2.3K reputationPosted Aug 11, 2024, 3:29 PM EDT
Thanks can yoou share the fixed code.?