Am I missing something or asp.net core allows to post script tag in user text fields? In Previous versions of asp.net mvc I needed to allow it by [AllowHtml] attribute.
ASP.NET Core does not have a feature similar to Request validation, as Microsoft decided, that it’s not a good idea. For more information see the discussion on the ASP.NET Core issue 'Default middleware for request validation, like IIS has'.
That means that validation has to take place on the inbound model. And that in the Razor (.cshtml)
you should output user provided input like @Model.Content
, which encodes the given string.
Please bear in mind that those escaping techniques might not work when the text that was output is not inside a Html part.
So don't use @Html.Raw(..)
unless you know that the data provided has been sanitized.
Supplement: