-
Notifications
You must be signed in to change notification settings - Fork 2.1k
OkObjectResult with string value outputs plain text only, no json. #6646
Comments
Is the response |
There response is always: Hello |
@dougbu if this looks like a bad regression we should consider patching it, so let me know. |
I'm unable to reproduce this with ASP.NET Core, testing both the released What I'm seeingFor example the PowerShell command The action returns bare
|
@aliveli186 - what's your startup code look like (just need the |
@rynowak Yes I'm using AddMvc().
AddJsonOptions has no effect on the result. |
@dougbu By the way this happens in: netcoreapp1.1 |
Ah, that explains why I can't hit this using 2.0.0! You're hitting #4945 and we fixed that issue in 2.0.0. The 1.1.x workaround is to add the following to the services.AddMvc(options => options.OutputFormatters.RemoveType<StringOutputFormatter>()); @Eilon I suspect the behaviour changes we made for #4945 were thought too significant for a patch. But, perhaps we should reconsider? (The recent #6657 issue also touched on the new behaviour.) |
Yeah I don't see how we'd patch that, it's a pretty significant change. |
Given that I don't see a reasonable way to patch in 1.x, and there's an easy to use workaround, and that it's fixed in 2.0, I'm closing this issue. Thanks! |
unless I am not understanding the issue, I think adding the [Produces("application/json")] decorator to the class should address the problem |
The method above always returns plain text (Hello) content instead of ("Hello") even if the request has "Accept: application/json" header.
The text was updated successfully, but these errors were encountered: