The Chrome debugger is showing the name as “GetPurchaseOrdersComponent” and the path as “/Cost”, whereas calls made by Telerik grid controls have the name “4485” and path “/Cost/GetPurchaseOrders” (and they are working). Also, the type on my call (when viewed in Chrome’s debugger) is text/html, whereas on the working calls, it’s application/json. The error I’m getting is: “500 (Internal Server Error)”. I have a similar route defined for this call as for the other calls. Here’s my code:
$.ajax({
url: "/Cost/GetPurchaseOrdersComponent",
type: "GET",
dataType: "json",
contentType: "application/json; charset=utf-8",
async: true,
data: { id: 1 },
success: function (result) {
$("#ComponentsMultiLevelGrid").html(result);
}
});
[HttpGet]
public string GetPurchaseOrdersComponent(int id)
{
return "some string";
}
UPDATE:
Here’s the header from a call that works (this call is from a Telerik grid):
Request URL:http://localhost:61751/Cost/GetSupplierCatalogs/4485?key=4485&_=1340830508447
Request Method:POST
Status Code:200 OK
**Request Headers** - view source
Accept:text/plain, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:13
Content-Type:application/x-www-form-urlencoded
Cookie:ASP.NET_SessionId=uxn1ctvzcchyrbreymcgz1vl
Host:localhost:61751
Origin:http://localhost:61751
Referer:http://localhost:61751/Transaction/4485
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
X-Requested-With:XMLHttpRequest
**Query String Parameters** - view URL encoded
key:4485
_:1340830508447
Form Dataview URL encoded
page:1
size:5
**Response Headers** - view source
Cache-Control:private
Connection:Close
Content-Length:21
Content-Type:application/json; charset=utf-8
Date:Wed, 27 Jun 2012 20:55:28 GMT
Server:ASP.NET Development Server/10.0.0.0
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:3.0
Here’s the header from the call that’s failing (this is the jQuery call):
Request URL:http://localhost:61751/Cost/GetPurchaseOrdersComponent?id=1
Request Method:GET
Status Code:500 Internal Server Error
**Request Headers** - view source
Accept:text/plain, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Type:application/x-www-form-urlencoded
Cookie:ASP.NET_SessionId=uxn1ctvzcchyrbreymcgz1vl
Host:localhost:61751
Referer:http://localhost:61751/Transaction/4485
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
X-Requested-With:XMLHttpRequest
**Query String Parameters** - view URL encoded
id:1
**Response Headers** - view source
Cache-Control:private
Connection:Close
Content-Length:10434
Content-Type:text/html; charset=utf-8
Date:Wed, 27 Jun 2012 20:55:25 GMT
Server:ASP.NET Development Server/10.0.0.0
X-AspNet-Version:4.0.30319
This works. Don’t ask me why.