Posted by Phil in ASP.NET MVC
on Sep 6th, 2012 | Comments Off on Creating a proxy with ApiController
I’ve recently moved to MVC 4, and as part of the clean up work I’ve moved a lot of methods I use for AJAX operations to the new ASP.NET Web API, on controllers that inherit from ApiController.
When it came to migrate a proxy action, I was amazed to find how much easier it is to build a proxy, with the method only taking a couple of lines.
A couple of notes on what’s in here:
Ideally I wouldn’t be modifying the original Request object, I’d really like to copy it into a new instance, but I couldn’t find a way to easily do it.
I’m not 100% sure why, but for GET requests the Content property is not null which causes HttpClient to error with a protocol violation exception.
– Phil
Comments are closed.
About Me
I'm primarily a .NET developer, an architect and a rationalist. I dabble in F#, node.js and other tools and techniques that might make me a better developer and I'd like to share what I learn.