Equivalent of Html.RenderAction in ASP.NET Core

I was finally able to do it with ViewComponent. So, instead of RenderAction(), I did: @section xyz{ @await Component.InvokeAsync(“abc”) } Where abc is a class as abcViewComponent. The ViewComponent looks like: public class abcViewComponent : ViewComponent { private DbContextOptions<MyContext> db = new DbContextOptions<MyContext>(); public async Task<IViewComponentResult> InvokeAsync() { MyContext context = new MyContext(db); IEnumerable<tableRowClass> mc … Read more

Html.Partial vs Html.RenderPartial & Html.Action vs Html.RenderAction

Html.Partial returns a String. Html.RenderPartial calls Write internally and returns void. The basic usage is: // Razor syntax @Html.Partial(“ViewName”) @{ Html.RenderPartial(“ViewName”); } // WebView syntax <%: Html.Partial(“ViewName”) %> <% Html.RenderPartial(“ViewName”); %> In the snippet above, both calls will yield the same result. While one can store the output of Html.Partial in a variable or return … Read more