ASP.NET MVC RenderAction re-renders entire page

How to prevent the rendering of the main page and its return? I just want it to display 1 section, for example.

Controller

public ActionResult PaymentOptions() { return View(settingService.GetPaymentBanks().ToList()); } 

View PaymentOptions:

 @model IEnumerable<Econo.Domain.PaymentBank> <h2>Payments</h2> <!-- Stuff here --> 

View

 <div class="grid_10"> </div> <div class="grid_14"> @{Html.RenderAction("PaymentOptions", "Administrator");} </div> 

Grid_14 displays the header, footer, and everything else. Is there any way to prevent this?

+6
source share
2 answers
 public ActionResult PaymentOptions() { return PartialView(settingService.GetPaymentBanks().ToList()); } 

In Razor, partial views and full views have the same extension, so you need to explicitly use the PartialViewResult result type to specify the partial view.

+11
source

It:

 return View(settingService.GetPaymentBanks().ToList()); 

You must use overload to specify the master:

 return View("PaymentOptions", "", settingService.GetPaymentBanks().ToList()); 
0
source

Source: https://habr.com/ru/post/889227/


All Articles