.net core multiple viewmodels code example

Example: asp.net mvc render multiple partial views

// You can't reutrn multiple partial views.
// However you can by pass this by simply looping a action

// in your .cshtml use Razor:

@{
  	// Note! Using this method you can't pass JS variables;
	// they are loaded in runtime 
	int loopThisManyTimes = 10;
	for (int i = 0; i < loopThisManyTimes; i++)
	{
      	MyModel model = new MyModel();
		Html.RenderPartial("<Your view name>", model);	
	}
}

// Or use JQuery:

$.ajax({
    type: "POST",
    url: '<Your URL>',
    contentType: "application/text; charset=utf-8",
    dataType: "text",
    success: function (data) {
        $("<Your container id>").html(data);
    },
    error: function (errData) {
      	// An error occured!
        $("<Your container id>").html(errData);
    }
});