-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Return ObjectResult - Without Double Quotes #4146
Comments
I suppose the response is being sent back as json, hence the double quotes. This sounds like a bug. Meanwhile you can return a |
I actually need a dynamic content type based on a number of conditions. |
I see. You could add the |
This is not a bug. This comes up from time to time and the recommendation is to use the string output formatter if you want strings to go onto the wire as-is.
This changed for RC2. If the returned object is a string, it can write any content type.
If you can give us more information about what you're trying to do we can help. |
Sounds like RC2 has a way to return a ContentResult and make sure it doesn't include double quotes around string values, with the additional control of setting the content type? Let me know if I understand that correctly. Which means I'll have to wait to upgrade since I'm buried in building in RC1. |
This has been around forever: https://github.com/aspnet/Mvc/blob/master/src/Microsoft.AspNet.Mvc.ViewFeatures/Controller.cs#L471
|
@rynowak I think you should reconsider this.
As you can see, the server does advertise that it is serializing JSON in I think moving the |
I agree, this doesn't seem right or useful. |
@jods, see #4945 (comment) We're planning to change this behavior for 2.0. I'm going to close this issue because I've already got a long-winded explanation including our future plans in #4945 |
Is there such thing as a RawResult? ObjectResult has some annoying behaviour that if you submit a string as the value it will always include double quotes in the response regardless of the ContentType you specify.
I want to ensure no double quotes are included in the response.
The text was updated successfully, but these errors were encountered: