dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.17k stars 9.93k forks source link

ArgumentNullException when requesting a Razor Page #56879

Open GauteHaugen opened 1 month ago

GauteHaugen commented 1 month ago

Hi, we have a hard-to-reproduce issue and are struggling to find a solution. We serve pages using a custom implementation of the IFileProvider and IFileInfo. On rare occasions, a page request will get a 500 response, and we can find this Exception/StackTrace in our logs:

System.ArgumentNullException: Value cannot be null. (Parameter 'type')
   at System.ArgumentNullException.Throw(String paramName)
   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.CompiledPageActionDescriptorFactory.CreateCompiledDescriptor(PageActionDescriptor actionDescriptor, CompiledViewDescriptor viewDescriptor)
   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.DefaultPageLoader.LoadAsyncCore(PageActionDescriptor actionDescriptor, EndpointMetadataCollection endpointMetadata)
   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageLoaderMatcherPolicy.ApplyAsyncAwaited(PageLoader pageLoader, CandidateSet candidates, Task`1 actionDescriptorTask, Int32 index)
   at Microsoft.AspNetCore.Routing.Matching.DfaMatcher.SelectEndpointWithPoliciesAsync(HttpContext httpContext, IEndpointSelectorPolicy[] policies, CandidateSet candidateSet)
   at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatch|10_1(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task matchTask)

Once a page gets this error, every user requesting the same page will get this error. At the moment, we can only resolve this by restarting the server. Nothing seems to be wrong with the Razor page, as a server restart always resolves the issue.

Is there anything about how we provide a page to the file provider that can result in this exception?

chsienki commented 1 month ago

This looks like a runtime razor issue. Transfering to http://github.com/dotnet/aspnetcore

//CC @mkArtakMSFT @javiercn

GauteHaugen commented 4 weeks ago

@mkArtakMSFT @javiercn Hi, would it be possible for someone to take a look at this? We are having this issue more frequently, and we cannot see anything wrong from our side at the moment.