0

I've an ASP.NET MVC project, where I use the WCF Web Api (Preview 6), and I want to use this to support a simple JSON service that supports JSONP. The JSON part of the service I got up and running pretty easy, but I've got some problems with the JSONP part of it.

Based on Alexander Zeitler's excellent post, I got the idea to use a Response Handler to support JSONP with the callback parameter, but I can figure out how to add this response handler to the HttpConfiguration (with WCF Web Api Preview 6).

My code in Global.ascx.cs looks something like this:

var catalog = new AssemblyCatalog(typeof(MvcApplication).Assembly);
var container = new CompositionContainer(catalog);        
var config = new HttpConfiguration() { EnableTestClient = true };

config.MessageHandlerFactory = () => container.GetExportedValues<DelegatingHandler>();

//config.ResponseHandlers <-- what to do here???

The message handler factory takes care of explicitly returning a JSON requests when using the /json in the URL.

PropellerHead
  • 929
  • 1
  • 12
  • 27

1 Answers1

0

You might want to take a look at how Phil Haack implemented the [Authorize] attribute using the Web Api. Implementing an Authorization Attribute for WCF Web API

In that example he appends an additional (custom) handler. I'm sure you could use the same code to replace an existing handler.

David Savage
  • 760
  • 5
  • 15