-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Open
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-rdfhelp wantedUp for grabs. We would accept a PR to help resolve this issueUp for grabs. We would accept a PR to help resolve this issue
Milestone
Description
Is there an existing issue for this?
- I have searched the existing issuesTo pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Describe the bug
I have a Minimal API with the following endpoint:
app.MapPost("/api/documents", ([FromForm] string[] values) =>
{
return TypedResults.Ok();
});
When I run the project, I get the following exception:
An unhandled exception has occurred while executing the request.
System.InvalidOperationException: TryParse method found on string with incorrect format. Must be a static method with format
bool TryParse(string, IFormatProvider, out string)
bool TryParse(string, out string)
but found
static Boolean TryParse(System.ReadOnlySpan`1[System.Char], System.IFormatProvider, System.String ByRef)
If I try with other types, like int[]
, it works correctly.
Exceptions (if any)
An unhandled exception has occurred while executing the request.
System.InvalidOperationException: TryParse method found on string with incorrect format. Must be a static method with format
bool TryParse(string, IFormatProvider, out string)
bool TryParse(string, out string)
but found
static Boolean TryParse(System.ReadOnlySpan`1[System.Char], System.IFormatProvider, System.String ByRef)
at Microsoft.AspNetCore.Http.ParameterBindingMethodCache.<FindTryParseMethod>g__Finder|18_0(Type type)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.AspNetCore.Http.ParameterBindingMethodCache.HasTryParseMethod(Type type)
at Microsoft.AspNetCore.Http.RequestDelegateFactory.CreateArgument(ParameterInfo parameter, RequestDelegateFactoryContext factoryContext, Boolean& hasTryParse, Boolean& hasBindAsync, Boolean& isAsParameters)
at Microsoft.AspNetCore.Http.RequestDelegateFactory.CreateArguments(ParameterInfo[] parameters, RequestDelegateFactoryContext factoryContext)
at Microsoft.AspNetCore.Http.RequestDelegateFactory.CreateArgumentsAndInferMetadata(MethodInfo methodInfo, RequestDelegateFactoryContext factoryContext)
at Microsoft.AspNetCore.Http.RequestDelegateFactory.InferMetadata(MethodInfo methodInfo, RequestDelegateFactoryOptions options)
at Microsoft.AspNetCore.Routing.RouteEndpointDataSource.CreateRouteEndpointBuilder(RouteEntry entry, RoutePattern groupPrefix, IReadOnlyList`1 groupConventions, IReadOnlyList`1 groupFinallyConventions)
at Microsoft.AspNetCore.Routing.RouteEndpointDataSource.get_Endpoints()
at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.CreateEndpointsUnsynchronized()
at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.EnsureEndpointsInitialized()
at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.get_Endpoints()
at Microsoft.AspNetCore.Routing.DataSourceDependentCache`1.Initialize()
at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory)
at Microsoft.AspNetCore.Routing.Matching.DataSourceDependentMatcher..ctor(EndpointDataSource dataSource, Lifetime lifetime, Func`1 matcherBuilderFactory)
at Microsoft.AspNetCore.Routing.Matching.DfaMatcherFactory.CreateMatcher(EndpointDataSource dataSource)
at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.InitializeCoreAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatcher|10_0(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task`1 matcherTask)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
.NET Version
9.0.301
pampua84, mikedepetris, totti240282, dcube9 and ranma42
Metadata
Metadata
Assignees
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-rdfhelp wantedUp for grabs. We would accept a PR to help resolve this issueUp for grabs. We would accept a PR to help resolve this issue
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
[-]InvalidOperationException when using string[] parameters with [FromForm] attribute[/-][+]InvalidOperationException when using string[] parameters with FromForm attribute[/+]captainsafia commentedon Aug 2, 2025
I think this bug is in RDF and is a combination of the interactions between POST metods + [FromForm] attributes + array-based types. Similar issues don't occur when PublishAoT=true and the source generator is at play.
Moving to the backlog for now given prioritization although PRs are welcome. I suspect the bug is related to the logic in thttps://github.com/dotnet/aspnetcore/blob/5d0e0d0dc65d9018faa1d9ce7892e7f4b6238b9d/src/Http/Http.Extensions/src/RequestDelegateFactory.cs#L763.
dotnet-policy-service commentedon Aug 2, 2025
Looks like this issue has been identified as a candidate for community contribution. If you're considering sending a PR for this issue, look for the
Summary Comment
link in the issue description. That comment has been left by an engineer on our team to help you get started with handling this issue. You can learn more about our Help Wanted process here