Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

revert Inferred parameters are not always recognized correctly (#485) first, (OCC-288) #489

Open
infofromca opened this issue Aug 30, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@infofromca
Copy link
Contributor

infofromca commented Aug 30, 2024

Describe the bug

A clear and concise description of what the problem is.

To Reproduce

Steps to reproduce the behavior:

  1. Go to builder.MapPost("api/shoppingcart/add-item",

  2. See error, could not hit the api server
    POST /api/shoppingcart/add-item HTTP/1.1
    Host: localhost:62354
    Transfer-Encoding: chunked
    Content-Type: application/json; charset=utf-8

{"Token":"4aqdbe0zbwa54scsx0w34efknc","ShoppingCartId":"4aqdbe0zbwa54scsx0w34efknc","Line":{"Quantity":1,"ProductSku":"TESTDISCOUNTEDPRODUCT","Attributes":null}}HTTP/1.1 500 Internal Server Error
Transfer-Encoding: chunked
Content-Type: text/plain; charset=utf-8
Server: Microsoft-IIS/10.0
Content-Security-Policy: base-uri 'self'; default-src 'self'; frame-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; form-action 'self'; img-src 'self' data:; object-src 'none'; frame-ancestors 'self'
X-Powered-By: ASP.NET
Date: Fri, 30 Aug 2024 18:49:06 GMT

System.InvalidOperationException: No service for type 'Microsoft.AspNetCore.Http.HttpContext' has been registered.
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at lambda_method49(Closure, Object, HttpContext, Object)
at Microsoft.AspNetCore.Http.RequestDelegateFactory.<>c__DisplayClass102_2.<b__2>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Builder.ApplicationBuilderExtensions.<>c.<b__1_0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Builder.ApplicationBuilderExtensions.<>c__DisplayClass0_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at OrchardCore.Apis.GraphQL.GraphQLMiddleware.Invoke(HttpContext context, IAuthorizationService authorizationService, IAuthenticationService authenticationService, ISchemaFactory schemaService, IDocumentWriter documentWriter)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext httpContext, Boolean retry)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at OrchardCore.Liquid.ScriptsMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
at OrchardCore.Diagnostics.DiagnosticsStartupFilter.<>c__DisplayClass3_0.<b__1>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
at OrchardCore.ContentPreview.PreviewStartupFilter.<>c.<b__0_1>d.MoveNext()
--- End of stack trace from previous location ---
at OrchardCore.Modules.ModularTenantRouterMiddleware.Invoke(HttpContext httpContext)
at OrchardCore.Modules.ModularTenantContainerMiddleware.<>c__DisplayClass4_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func2 execute, Boolean activateShell) at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func2 execute, Boolean activateShell) at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Modules.ModularTenantContainerMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

HEADERS

Content-Type: application/json; charset=utf-8
Host: localhost:62354
Transfer-Encoding: chunked

Expected behavior

revert Inferred parameters are not always recognized correctly (#485) first,

private static async Task AddItemAsync(
[FromBody] AddItemViewModel addItemVM,
// [FromServices]
IAuthorizationService authorizationService,
// [FromServices]
HttpContext httpContext,
// [FromServices]
IShoppingCartService shoppingCartService,
// [FromServices]
IHtmlLocalizer htmlLocalizer
)

Screenshots

屏幕截图 2024-08-30 145759

Jira issue

@infofromca infofromca added the bug Something isn't working label Aug 30, 2024
@github-actions github-actions bot changed the title revert Inferred parameters are not always recognized correctly (#485) first, revert Inferred parameters are not always recognized correctly (#485) first, (OCC-288) Aug 30, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant