__Scenario__: A user has an action filter where he likes to re-read the incoming request stream.
__Current behavior__:
In Katana/WCF selfhosts, currently this piece of code would print like "At CustomActionFilter:Hello!"(Notice that I am trying to reread the request content in action filter even though the content has already been used to bind the Post action method)
```
public class CustomActionFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(HttpActionContext actionContext)
{
string requestData = actionContext.Request.Content.ReadAsStringAsync().Result;
Console.WriteLine("At CustomActionFilter:{0}", requestData);
}
}
public class ValuesController : ApiController
{
[CustomActionFilter]
public string Post([FromBody]string value)
{
return value;
}
}
```
__Issue__: However, this is not the same behavior in WebHost, where the user would see "At CustomActionFilter:" (notice there is no 'Hello!')
__Reason__:
For self-hosted(Katana/WCF) applications, the content stream can be read even after the model binding because it’s eagerly loaded into buffer at the hosting layers. Like in Web API's OWIN adapter, we call LoadIntoBufferAsync which eagerly loads all content into buffer.
__Attached__ a katana selfhost repro. (NOTE: To repro the problem in WebHost, just copy the filter attribute and ValuesController code and you should see the issue repro-ing)
__Current behavior__:
In Katana/WCF selfhosts, currently this piece of code would print like "At CustomActionFilter:Hello!"(Notice that I am trying to reread the request content in action filter even though the content has already been used to bind the Post action method)
```
public class CustomActionFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(HttpActionContext actionContext)
{
string requestData = actionContext.Request.Content.ReadAsStringAsync().Result;
Console.WriteLine("At CustomActionFilter:{0}", requestData);
}
}
public class ValuesController : ApiController
{
[CustomActionFilter]
public string Post([FromBody]string value)
{
return value;
}
}
```
__Issue__: However, this is not the same behavior in WebHost, where the user would see "At CustomActionFilter:" (notice there is no 'Hello!')
__Reason__:
For self-hosted(Katana/WCF) applications, the content stream can be read even after the model binding because it’s eagerly loaded into buffer at the hosting layers. Like in Web API's OWIN adapter, we call LoadIntoBufferAsync which eagerly loads all content into buffer.
__Attached__ a katana selfhost repro. (NOTE: To repro the problem in WebHost, just copy the filter attribute and ValuesController code and you should see the issue repro-ing)