Skip to content

Callback function not being included in response #32

Open
@mii9000

Description

I have the following in my Web API action:

[HttpGet]
public HttpResponseMessage GetProducts(string id)                
{
      var returnData = data;
      string callback = ControllerContext.Request.GetQueryNameValuePairs().Where(kv => kv.Key == "callback").Single().Value;    
      return Request.CreateResponse(HttpStatusCode.OK, returnData, new JsonpMediaTypeFormatter(new JsonMediaTypeFormatter(),callback), new MediaTypeHeaderValue("text/javascript"));
}

But it is responding with:
({.....}); instead of myCallback({....});

Where am I going wrong?

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions