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
3 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Tuhin PaulPosted Aug 11, 2024, 3:29 PM
Mark TaborPosted Aug 11, 2024, 7:29 PM
Thanks can yoou share the fixed code.?
Tuhin PaulPosted Aug 11, 2024, 3:28 PM
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.