View Component not loading partial view data synchronously

306 Views Asked by At

I am running one Asp.Net Core MVC project 3.1 where i have one layout.cshtml page.

Here i used few filters to use across all the pages.

To load filters and to load data there i am using DevExtreme control where it first load the partial view using view component and inside specific partial view whatever the action and controller name defined it will hit there and load the data from there.

like below is my layout page where i am calling same view component name passing with two different param to load the specific partial:

 <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 div-float-left filter-text-col">
 <label><b>Filter1</b></label><br>
  <vc:load-filters filter-type="filter1"></vc:load-filters>
 </div>
 
 <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 div-float-left filter-text-col">
 <label><b>Filter2</b></label><br>
  <vc:load-filters filter-type="filter2"></vc:load-filters>
 </div>
                                    
 

Then below is the view compoenent used to load the specific partial view:

 public IViewComponentResult Invoke(string filterType)
        {
            string viewName = string.Empty;
            switch (filterType.ToLower())
            {
                case "filter1":
                    viewName = "_Filter1Partial";
                    break;
                case "filter2":
                    viewName = "_Filter2Partial";
                    break;
            }
            return View(viewName);
        }

Then for each partial view have devextreme control which calls there related action method.

Current Scenario: But when i put break point in both action method, e:g ActionMethod1 and ActionMethod2

Then i can see here process is not finishing up the ActionMethod1 and call ActionMethod2.

Expected Scenario: But ActionMethod2 is depend on ActionMethod1.

In ActionMethod1 i set some value and when call ActionMethod2 there we get that value and load the data based on it.

In a simple word, I need here once first ActionMethod1 would get over, ActionMethod2 should get call.

Note: In MVC project i used @Html.RenderAction and using it is working fine.

But due to the process is calling both ActionMethod asynchronously, Filters are not working correctly.

Please suggest.

0

There are 0 best solutions below