Created
November 23, 2016 13:18
-
-
Save stevejgordon/0f54c4dd4fccefd744229b485f253619 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class MvcOptionsExtensions | |
| { | |
| public static void UseHtmlEncodeModelBinding(this MvcOptions opts) | |
| { | |
| var binderToFind = opts.ModelBinderProviders.FirstOrDefault(x => x.GetType() == typeof(SimpleTypeModelBinderProvider)); | |
| if (binderToFind == null) return; | |
| var index = opts.ModelBinderProviders.IndexOf(binderToFind); | |
| opts.ModelBinderProviders.Insert(index, new HtmlEncodeModelBinderProvider()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment