Do I need to encode attribute values in MVC Razor?
问题 In a cshtml file, I'm assigning a string to an attribute. For example: <input name="somename" value="@Model.Value"> Since @Model.Value string could contain any Unicode character, obviously the string must be encoded. Will Razor encode this value automatically? I'm guessing it won't or can't because I could easily put a @Html.Raw immediately after it to break up the whole thing into two tags. I think what I need to do is this: <input name="somename" value="@Html.Raw(Html.AttributeEncode(Model