I want to override the buffered input stream for a particular end point which is responsible for upload the files.
I've been following the advice in the great article here:
http://www.strathweb.com/2012/09/dealing-with-large-files-in-asp-net-web-api/
And this approach works whenever a templating approach to routing is taken. Like this:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
However, whenever I use attribute based routing,
config.MapHttpAttributeRoutes();
Then the RouteData is never populated:
public override bool UseBufferedInputStream(object hostContext)
{
var context = hostContext as HttpContextBase;
if (context != null && context.Request.RequestContext.RouteData.Values.Count>0)
{
if (string.Equals(context.Request.RequestContext.RouteData.Values["controller"].ToString(), "values", StringComparison.InvariantCultureIgnoreCase))
return false;
}
return true;
}
Is there another approach I can use, a different way of checking the route data for the request, in order to determine if I want the input buffered?