Skip to content

Instantly share code, notes, and snippets.

@neoGeneva
Created September 6, 2012 21:23
Show Gist options
  • Save neoGeneva/3660470 to your computer and use it in GitHub Desktop.
Save neoGeneva/3660470 to your computer and use it in GitHub Desktop.
Proxy using ApiController
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using Http = System.Net.WebRequestMethods.Http;
namespace PhilsVersion
{
public class ProxyController : ApiController
{
[AcceptVerbs(Http.Get, Http.Head, Http.MkCol, Http.Post, Http.Put)]
public async Task<HttpResponseMessage> Proxy(string url)
{
using (HttpClient http = new HttpClient())
{
this.Request.RequestUri = new Uri(url);
if (this.Request.Method == HttpMethod.Get)
{
this.Request.Content = null;
}
return await http.SendAsync(this.Request);
}
}
}
}
@JobaDiniz
Copy link

This really works?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment