I have an ASP.NET MVC app that I am trying to migrate to MVC 6 (ASP.NET 5). With that in mind, I have some filters that were added using the process described in this SO post. However, with Global.asax being replaced with Startup.cs, I'm not sure where to add my global filters anymore.
In addition, in my filter I have:
public override void OnResultExecuting(ResultExecutingContext context)
{
context.Controller.ViewBag.MyProperty = "[TESTING]";
}
When I run dnx . run
now, I get an error that says:
MyFilter.cs(11,22): error CS1061: 'object' does not contain a definition for 'ViewBag' and no extension method 'ViewBag' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
How do I add global filters in ASP.NET 5 (MVC 6)?