Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Closed Unassigned: MAJOR Issue with MVC 5.1/ Web API + Jquery [1664]

$
0
0
As of the 5.1 update you've introduced a serious issue in to Request.CreateResponse.

If you return Request.CreateResponse(HttpStatusCode.OK) (or Accepted or any other success code) and the jquery ajax call is setup something like this:

```
$.ajax({
type: "PUT",
url: url,
dataType: "json",
data: value == null ? null : JSON.stringify(value),
contentType: "application/json; charset=utf-8",
```

even though Request.CreateResponse is returning OK it will fail.

And before you say don't set the dataType to json if it isn't expecting a json response, lots of us have a lot of code that is generic for calling web api, and this isn't feesible because it would then have to know if it should be getting a value response back or not.

Web API used to return "no content" in the headers in the above CreateResponse example with no value, as it should. It now is not.

I would classify this as a massively breaking change that needs to be fixed ASAP and a public stable point release produced to fix it.
Comments: The breaking change came from jQuery. There are actually no changes in WebAPI. Also note that your code explicitly sets the StatusCode to 202 or 200, and we will never change that because that is an unexpected behavior. Your solution seems like a reasonable workaround (just for your specific case), and I'd recommend following on the jQuery site.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>