diff --git a/samples/MvcSample/Filters/InspectResultPageAttribute.cs b/samples/MvcSample/Filters/InspectResultPageAttribute.cs new file mode 100644 index 0000000000..a0a78f9faa --- /dev/null +++ b/samples/MvcSample/Filters/InspectResultPageAttribute.cs @@ -0,0 +1,27 @@ +using System; +using System.Threading.Tasks; +using Microsoft.AspNet.Mvc; +using MvcSample.Models; + +namespace MvcSample.Filters +{ + public class InspectResultPageAttribute : ActionResultFilterAttribute + { + public async override Task Invoke(ActionResultFilterContext context, Func next) + { + ViewResult viewResult = context.Result as ViewResult; + + if (viewResult != null) + { + User user = viewResult.ViewData.Model as User; + + if (user != null) + { + user.Name += "**" + user.Name + "**"; + } + } + + await next(); + } + } +} diff --git a/samples/MvcSample/FiltersController.cs b/samples/MvcSample/FiltersController.cs index 528cb49109..e682a4d752 100644 --- a/samples/MvcSample/FiltersController.cs +++ b/samples/MvcSample/FiltersController.cs @@ -17,6 +17,7 @@ namespace MvcSample // TODO: Add a real filter here [ServiceFilter(typeof(PassThroughAttribute))] [AgeEnhancer] + [InspectResultPage] public IActionResult Index(int age) { _user.Age = age; diff --git a/samples/MvcSample/project.json b/samples/MvcSample/project.json index f41f402b77..6d883683c2 100644 --- a/samples/MvcSample/project.json +++ b/samples/MvcSample/project.json @@ -5,6 +5,7 @@ "Microsoft.AspNet.ConfigurationModel": "0.1-alpha-*", "Microsoft.AspNet.DependencyInjection" : "0.1-alpha-*", "Microsoft.AspNet.Routing" : "0.1-alpha-*", + "Microsoft.AspNet.Mvc.ModelBinding" : "", "Microsoft.AspNet.Mvc.Core" : "", "Microsoft.AspNet.Mvc" : "", "Microsoft.AspNet.Mvc.Razor": ""