Skip to content
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

Closed
1 task done
davhdavh opened this issue Feb 24, 2023 · 3 comments
Closed
1 task done

Razor pages handlers does not support IConvertToActionResult #46855

davhdavh opened this issue Feb 24, 2023 · 3 comments
Labels
area-ui-rendering Includes: MVC Views/Pages, Razor Views/Pages investigate

Comments

@davhdavh
Copy link
Contributor

davhdavh commented Feb 24, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.CreateHandlerMethod(HandlerMethodDescriptor handlerDescriptor) only accepts void and IActionResult (and Task variants of same), but it does not support the already declared interface that lets your return type convert to an IActionResult, namely the Microsoft.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

public class MyPageModel : PageModel {
   public ActionResult<bool> OnPostMyHandler() => true;
}

Exceptions (if any)

An unhandled exception occurred while processing the request.
InvalidOperationException: Unsupported handler method return type 'Microsoft.AspNetCore.Mvc.ActionResult1[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.ActionResult1[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

@mkArtakMSFT mkArtakMSFT added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Feb 24, 2023
@javiercn javiercn added this to the .NET 8 Planning milestone Mar 1, 2023
@ghost
Copy link

ghost commented Mar 1, 2023

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.
We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. Because it's not immediately obvious what is causing this behavior, we would like to keep this around to collect more feedback, which can later help us determine how to handle this. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact work.

@captainsafia captainsafia added area-ui-rendering Includes: MVC Views/Pages, Razor Views/Pages and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Aug 25, 2023
@ghost
Copy link

ghost commented Oct 10, 2023

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.
We're moving this issue to the .NET 9 Planning milestone for future evaluation / consideration. Because it's not immediately obvious what is causing this behavior, we would like to keep this around to collect more feedback, which can later help us determine how to handle this. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact work.

@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@mkArtakMSFT
Copy link
Member

Hi. Thanks for contacting us.
We're closing this issue as there was not much community interest in this ask for quite a while now.
You can learn more about our triage process and how we handle issues by reading our Triage Process writeup.

@mkArtakMSFT mkArtakMSFT closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-ui-rendering Includes: MVC Views/Pages, Razor Views/Pages investigate
Projects
None yet
Development

No branches or pull requests

6 participants
@davhdavh @captainsafia @javiercn @wtgodbe @mkArtakMSFT and others