Running into issues using an action filter on a hijacked route - annoyingly, it works in some cases but not in all...
Normally looks like so:
namespace Foo.Web.Controllers.RenderMvcControllers
{
public class FooBarController : DefaultController
{
[ReplaceSpecificMarkupFilter]
public ActionResult FooBar(RenderModel renderModel)
{
var model = new FooBarViewModel(renderModel.Content);
return CurrentTemplate(model);
}
[ReplaceSpecificMarkupFilter]
public ActionResult AltFooBar(RenderModel renderModel)
{
var model = new AltFooBarViewModel(renderModel.Content);
return CurrentTemplate(model);
}
}
}
Where the filter replaces some markup, the named actions allow different method per template name, and everything should work fine (and does, for some content types).
When it fails, I get a super helpful error => "Filtering is not allowed"
I'm at a loss as to why this works for some types and not others. The controller code runs fine, models are built and correct, but when execution hits the filter, it is null:
public override void OnResultExecuted(ResultExecutedContext filterContext)
{
if ( filterContext.Exception != null)
{
return;
}
HttpResponseBase response = filterContext.HttpContext.Response;
ReplaceSpecificMarkupFilter filter = _replaceSpecificMarkupFilterCtor();
// response.Filter is sometimes null... It should not be.
response.Filter = new StreamFilterBase(response.Filter, filter.Filter);
}
Route hijacking and response filtering
Running into issues using an action filter on a hijacked route - annoyingly, it works in some cases but not in all...
Normally looks like so:
Where the filter replaces some markup, the named actions allow different method per template name, and everything should work fine (and does, for some content types).
When it fails, I get a super helpful error => "Filtering is not allowed"
I'm at a loss as to why this works for some types and not others. The controller code runs fine, models are built and correct, but when execution hits the filter, it is null:
Any legends have any amazing solutions?
is working on a reply...