There is an asynchronous method
ReportController.cs
public async Task<ActionResult> GetRMschools() { Account account = new Account("chr_coko.pto@mail.ru", "***"); var api = new MailRuCloud(); api.Account = account; string schoolID = User.Identity.Name; var items = await api.GetItems($@"/Reports/{schoolID}"); school school_current = schoolRepository.GetT(schoolID); List<RMschool> model = new List<RMschool>(); foreach (var file_name in items.Files) //eg file_name = "0001_201636.zip" { int report_code = Convert.ToInt32(file_name.Name.Substring(5, 6)); //eg report_code = 201636 var ob = monit95Context.ReportMetas.Find(report_code); model.Add(new RMschool { code = ob.code, name = ob.name, ProjectName = ob.ProjectName, year = ob.year, WWWref = $@"{school_current.ReportLink}/{file_name.Name}" }); } return PartialView("_GetRMschools", model); which causes a partial view
_GetRMschools.cshtml
@using Monit95App.Models @model List<RMschool> <body> <table class="table"> <thead class="thead-inverse"> <tr> <th>Проект</th> <th>Отчет</th> <th>Учебный год</th> </tr> </thead> @foreach (var reportMeta in Model.OrderByDescending(x => x.code)) { <tr> <td>@reportMeta.ProjectName</td> <td><a href="@reportMeta.WWWref">@reportMeta.name</a></td> <td>@reportMeta.year</td> </tr> } </table> </body> Now I am trying to get this partial view in another View.
Report.cshtml
<h2>Отчеты</h2> @Html.Action("GetRMschools") When running, displays:
Error executing child request for descriptor 'System.Web.Mvc.HttpHandlerUtil + ServerExecuteHttpHandlerAsyncWrapper'
HttpServerUtility.Execute is blocked until the end of the asynchronous operation.
- Why it happens?
- How to fix?
var items = api.GetItems($@"/Reports/{schoolID}").Result;- Ruslan_K