From 377d8cdcddee9dd5ec78f68dd6bc7a8dc6bd1976 Mon Sep 17 00:00:00 2001 From: Rachel Appel Date: Thu, 31 Aug 2017 21:45:30 +0200 Subject: [PATCH] Fixes #4067: formatters added note about order;change code (#4144) * formatters added note about order;change code * added space between sentences --- aspnetcore/mvc/advanced/custom-formatters.md | 2 ++ aspnetcore/mvc/advanced/custom-formatters/Sample/Startup.cs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/aspnetcore/mvc/advanced/custom-formatters.md b/aspnetcore/mvc/advanced/custom-formatters.md index 1c98550c23..a67e8274fc 100644 --- a/aspnetcore/mvc/advanced/custom-formatters.md +++ b/aspnetcore/mvc/advanced/custom-formatters.md @@ -91,6 +91,8 @@ To use a custom formatter, add an instance of the formatter class to the `InputF [!code-csharp[Main](custom-formatters/sample/Startup.cs?name=mvcoptions&highlight=3-4)] +Formatters are evaluated in the order you insert them. The first one takes precedence. + ## Next steps See the [sample application](https://github.com/aspnet/Docs/tree/master/aspnetcore/mvc/advanced/custom-formatters/Sample), which implements simple vCard input and output formatters. The application reads and writes vCards that look like the following example: diff --git a/aspnetcore/mvc/advanced/custom-formatters/Sample/Startup.cs b/aspnetcore/mvc/advanced/custom-formatters/Sample/Startup.cs index d8bf05c605..0f9974af68 100644 --- a/aspnetcore/mvc/advanced/custom-formatters/Sample/Startup.cs +++ b/aspnetcore/mvc/advanced/custom-formatters/Sample/Startup.cs @@ -29,8 +29,8 @@ namespace CustomFormatterDemo #region mvcoptions services.AddMvc(options => { - options.InputFormatters.Add(new VcardInputFormatter()); - options.OutputFormatters.Add(new VcardOutputFormatter()); + options.InputFormatters.Insert(0, new VcardInputFormatter()); + options.OutputFormatters.Insert(0, new VcardInputFormatter()); }); #endregion