I am using WebApiContrib.Formatting.Jsonp within a Web API 2 service, plus Swagger for API documentation and testing.
When I trigger any JSONP method through Swagger, my service crashes in file JsonpMediaTypeFormatter.cs on the following line:
throw new InvalidOperationException(Properties.Resources.NoCallback);
// NoCallback = The name 'NoCallback' does not exist in the current context
For one thing, I don't understand why Swagger doesn't allow specifying a callback name for JSONP requests. But more importantly, I don't want the service to crash because of it.
Questions:
- How can we handle such errors on the service side?
- Is there a way to make Swagger send JSONP requests properly? (like pre-defining a callback name for all JSONP requests?)