Skip to content

Instantly share code, notes, and snippets.

Created April 4, 2013 14:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/5311068 to your computer and use it in GitHub Desktop.
Save anonymous/5311068 to your computer and use it in GitHub Desktop.
public class FormHandler : DelegatingHandler
{
protected override System.Threading.Tasks.Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
{
if (request.Content != null && request.Content.Headers.ContentType != null &&
request.Content.Headers.ContentType.MediaType == "application/x-www-form-urlencoded")
{
var routeData = request.Properties["MS_HttpRouteData"] as IHttpRouteData;
var form = request.Content.ReadAsFormDataAsync().Result;
foreach (var key in form.AllKeys)
{
routeData.Values.Add(new KeyValuePair<string, object>(key, form[key]));
}
}
return base.SendAsync(request, cancellationToken);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment