C
C#2y ago
FusedQyou

❔ Why does my response get capitalized?

or some weird ass reason this small piece of code capitalizes the string I write to it. Notice false is not capitalized, but the actual response is. Why does this happen and how can I prevent this?
10 Replies
Buddy
Buddy2y ago
Are you sure that's not just Postman capitalizing it?
FusedQyou
FusedQyou2y ago
No, my frontend also receives it like this
Buddy
Buddy2y ago
It's currently set as 'Pretty' which may format it.
FusedQyou
FusedQyou2y ago
FusedQyou
FusedQyou2y ago
This is a problem because it's not parsed as a boolean anymore
HimmDawg
HimmDawg2y ago
Maybe .NET uses .ToString() for the bool, which evaluates to True/False
FusedQyou
FusedQyou2y ago
I doubt it since that would make it a string, and this is not even a string but a literal capitalized boolean value You might be right actually. I just checked and I expected quotes to form but it remains the same pretty much
Buddy
Buddy2y ago
You are correct.
FusedQyou
FusedQyou2y ago
This is weird though. I parse it beforehand so responseObject is a object holding a boolean. Why would it call ToString()? I have been working around the whole middleware in general, and I found out a way to copy the stream early before it even has to bother with the parsing or writing in general. This fixes my issue, but I wonder why this this happens in general?
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.