Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Edited Issue: RouteData not available to WebHost's buffer policy selector in certain scenarios [1158]

$
0
0
__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 is happening in following scenarios :

1. When attribute routing is used.
2. When conventional routing is used and the conventional route has route constraints.

```
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;
}
}

```

__Workaround__:
A user could be returning just 'false' always without checking the route data. Web API pipeline works just fine if the request is in streamed mode, but currently the problem is with __bug #1136__, which breaks MVC if we do so. Actually, I started out the current scenario as a workaround for that bug.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>