-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Razor pages handlers does not support IConvertToActionResult #46855
Comments
To learn more about what this message means, what to expect next, and how this issue will be handled you can read our Triage Process document. |
To learn more about what this message means, what to expect next, and how this issue will be handled you can read our Triage Process document. |
Hi. Thanks for contacting us. |
Is there an existing issue for this?
Describe the bug
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.CreateHandlerMethod(HandlerMethodDescriptor handlerDescriptor)
only acceptsvoid
andIActionResult
(and Task variants of same), but it does not support the already declared interface that lets your return type convert to anIActionResult
, namely theMicrosoft.AspNetCore.Mvc.Infrastructure.IConvertToActionResult
.Relevant code:
https://github.com/dotnet/aspnetcore/blob/main/src/Mvc/Mvc.RazorPages/src/Infrastructure/ExecutorFactory.cs#L28
Expected Behavior
Any class that implements
IConvertToActionResult
is a valid return value from razor page handler.Steps To Reproduce
Exceptions (if any)
An unhandled exception occurred while processing the request.
InvalidOperationException: Unsupported handler method return type 'Microsoft.AspNetCore.Mvc.ActionResult
1[System.Boolean]'. Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.CreateHandlerMethod(HandlerMethodDescriptor handlerDescriptor) Stack Query Cookies Headers Routing InvalidOperationException: Unsupported handler method return type 'Microsoft.AspNetCore.Mvc.ActionResult
1[System.Boolean]'.Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.CreateHandlerMethod(HandlerMethodDescriptor handlerDescriptor)
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.CreateExecutor(HandlerMethodDescriptor handlerDescriptor)
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvokerCache.GetHandlerExecutors(CompiledPageActionDescriptor actionDescriptor)
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvokerCache.CreateCacheEntry(CompiledPageActionDescriptor compiledActionDescriptor, FilterItem[] cachedFilters)
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvokerCache.GetCachedResult(ActionContext actionContext)
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageRequestDelegateFactory+<>c__DisplayClass13_0.b__0(HttpContext context)
Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+<>c__DisplayClass6_1+<b__1>d.MoveNext()
Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.OData.Batch.ODataBatchMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
.NET Version
since 2017
Anything else?
No response
The text was updated successfully, but these errors were encountered: