From e1069dbf65182e5f13ba6ee863711b61521a2b81 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Wed, 14 Jan 2015 18:35:20 -0800 Subject: [PATCH] Fix for #384 - And some other changes to controller as filter This is a major change to how we handle the scenario where a controller is a filter. We want to change the lifetime of the controller object, by scoping it around action filters and result filters. This means that a controller class can only implement action filters and result filters. To implement #384 - we're creating a delegating filter class 'ControllerFilter' which will forward calls to the implementation of the controller. This is discovered in the controller model and added to the filter collection. This filter is removable as an opt-out of this feature. The ControllerFilter only implements action filter and result filter, so the new restriction about filter types on Controller is in place. A future change will move the instantiation of the controller to after resource filters. --- src/Microsoft.AspNet.Mvc.Core/Controller.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.AspNet.Mvc.Core/Controller.cs b/src/Microsoft.AspNet.Mvc.Core/Controller.cs index e5ad680fa9..3220131163 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Controller.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Controller.cs @@ -59,7 +59,7 @@ namespace Microsoft.AspNet.Mvc { return ActionContext?.RouteData; } - } + } public ModelStateDictionary ModelState { @@ -113,7 +113,7 @@ namespace Microsoft.AspNet.Mvc return _viewData; } set - { + { if (value == null) { throw @@ -822,7 +822,7 @@ namespace Microsoft.AspNet.Mvc } /// - /// Updates the specified instance using values from the controller's current + /// Updates the specified instance using values from the controller's current /// and a . /// /// The type of the model object. @@ -847,7 +847,7 @@ namespace Microsoft.AspNet.Mvc } /// - /// Updates the specified instance using the and a + /// Updates the specified instance using the and a /// . /// /// The type of the model object. @@ -882,14 +882,14 @@ namespace Microsoft.AspNet.Mvc } /// - /// Updates the specified instance using values from the controller's current + /// Updates the specified instance using values from the controller's current /// and a . /// /// The type of the model object. /// The model instance to update. /// The prefix to use when looking up values in the current . /// - /// (s) which represent top-level properties + /// (s) which represent top-level properties /// which need to be included for the current model. /// A that on completion returns true if the update is successful [NonAction] @@ -920,7 +920,7 @@ namespace Microsoft.AspNet.Mvc } /// - /// Updates the specified instance using values from the controller's current + /// Updates the specified instance using values from the controller's current /// and a . /// /// The type of the model object. @@ -957,7 +957,7 @@ namespace Microsoft.AspNet.Mvc } /// - /// Updates the specified instance using the and a + /// Updates the specified instance using the and a /// . /// /// The type of the model object. @@ -965,7 +965,7 @@ namespace Microsoft.AspNet.Mvc /// The prefix to use when looking up values in the /// /// The used for looking up values. - /// (s) which represent top-level properties + /// (s) which represent top-level properties /// which need to be included for the current model. /// A that on completion returns true if the update is successful [NonAction] @@ -997,7 +997,7 @@ namespace Microsoft.AspNet.Mvc } /// - /// Updates the specified instance using the and a + /// Updates the specified instance using the and a /// . /// /// The type of the model object.