Minimal API string response - ArgumentNullException #65663
-
|
According to Create responses in Minimal API applications, a minimal API endpoint can return a However, this doesn't seem to work if the returned a request to the endpoint returns: Stack trace: Is this expected behaviour, or is it a bug? And if it's expected, shouldn't the docs be updated to explicitly call this out? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
I would say this is a bug and a misuse. It's a bug because the framework shouldn't be trying to write I would say it's a misuse because there's no way to write I'm not sure what the fix for the bug would be - either to throw an explicit exception for the misuse, or to just no-op and write nothing. |
Beta Was this translation helpful? Give feedback.
I would say this is a bug and a misuse.
It's a bug because the framework shouldn't be trying to write
nullto the response, it should probably just write nothing. Otherwise it hits the guard here that the method needs the text to have a value:aspnetcore/src/Http/Http.Abstractions/src/Extensions/HttpResponseWritingExtensions.cs
Line 29 in 552c986
I would say it's a misuse because there's no way to write
nullto a raw text/plain HTTP response.nullwould just semantically be the literal charactersnullbecause the response is just text.I'm not sure what the fix for the bug would be - either to throw an explicit exception for th…