__Scenario__:
User wishes to upload large files to a Web API service. He does not want these files to be buffered, so depending on the incoming request's route data (ex: controller, action), he either enables streamed or buffer mode.
__Issue__:
In the below code, "UserBufferInputStream" method isn't having any routedata available to perform the evaluation. This happens only for attribute routing generated routes as it goes through a certain path which conventional routes do not go through.
```
config.Services.Replace(typeof(IHostBufferPolicySelector), new CustomWebHostBufferPolicySelector());
public class CustomWebHostBufferPolicySelector : WebHostBufferPolicySelector
{
public override bool UseBufferedInputStream(object hostContext)
{
HttpContextBase contextBase = (HttpContextBase)hostContext;
RouteData routeData = contextBase.Request.RequestContext.RouteData;
object actions;
if (routeData.DataTokens != null && routeData.DataTokens.TryGetValue("actions", out actions))
{
//retrieve the controller name from action descriptors
}
return true;
}
}
```
User wishes to upload large files to a Web API service. He does not want these files to be buffered, so depending on the incoming request's route data (ex: controller, action), he either enables streamed or buffer mode.
__Issue__:
In the below code, "UserBufferInputStream" method isn't having any routedata available to perform the evaluation. This happens only for attribute routing generated routes as it goes through a certain path which conventional routes do not go through.
```
config.Services.Replace(typeof(IHostBufferPolicySelector), new CustomWebHostBufferPolicySelector());
public class CustomWebHostBufferPolicySelector : WebHostBufferPolicySelector
{
public override bool UseBufferedInputStream(object hostContext)
{
HttpContextBase contextBase = (HttpContextBase)hostContext;
RouteData routeData = contextBase.Request.RequestContext.RouteData;
object actions;
if (routeData.DataTokens != null && routeData.DataTokens.TryGetValue("actions", out actions))
{
//retrieve the controller name from action descriptors
}
return true;
}
}
```