Closed vitalybrandes closed 4 years ago
Can you provide some repro steps?
@sebastienros Well, i have Razor page where i query and Inject contentItems / Users
public async Task OnGetAsync()
{
CompanyName = await _contentManager.GetAsync(id);
var _Users = await _session.Query<User, UserByCompanyIndex>().Where(index => index.CompanyContentItemID == id).OrderBy(x => x.UserFirstName).ListAsync();
}
Then:
@{
var _companyName = OrchardInject.GetContentItemByIdAsync(Model.id);
}
and somewhere in the page i do for each ContentItemId in _CompanyName....something for the ConteNtitemPicker.
@foreach (string items in @Model.CompanyName.ContentItem.Content.Company.Printer.ContentItemIds)
{
var Printer = await OrchardInject.GetContentItemByIdAsync(items);
string _printerTypeId = Printer.ContentItem.Content.Printer.PrinterType.ContentItemIds[0];
var PrinterType = await OrchardInject.GetContentItemByIdAsync(_printerTypeId);
}
i have feeling that i have problem with the for each loop. As after refresh, the error not exist and everything loaded perfectly.
You are missing the await keyword in var _companyName = OrchardInject.GetContentItemByIdAsync(Model.id);
You are missing the await keyword in
var _companyName = OrchardInject.GetContentItemByIdAsync(Model.id);
@sebastienros Ups, miss it, change to async but this didn't help, still the same
@vitalybrandes
Okay we had a similar issue because the mvc PageLoaderMatcherPolicy.ApplyAsync()
was not checking in its loop the validity of each candidate as in other policies, so we overridden it and opened this issue
if (!candidates.IsValidCandidate(i))
{
continue;
}
Regarding your trace PageLoaderMatcherPolicy.ApplyAsyncAwaited()
is called, maybe before this code path was not used, maybe because of this other change, and just saw that here also the validity of each candidate is not checked
I will open an issue on the dotnet aspnetcore repo
Meanwhile we could override the PageLoaderMatcherPolicy
as we already did at some point, or just wait for the issue to be fixed ;)
@jtkech Thank you! From your experience, how long to wait for the fix?
@vitalybrandes
It has been moved to the Next sprint planning
milestone, so i think around one month
Our milestones are usually a month long. Before each milestone we have one or more planning meetings, where we look through all the accumulated issues in the
Next Sprint Planning
milestone ...
@vitalybrandes maybe it will be quicker if you create the PR in aspnet, including a unit test.
can you also try to enable the fix described here? https://docs.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-3.1#route-template-reference
Not sure if this is Orchard issue, but ask anyway, .NET 3.1 Using Razor page, multi query for orchard content, for first page load get Null exceptions, once refresh the page, everything is ok. Happen only to page with multiple query's.
Error: