Is there a risk in using @Html.Raw
? It seems to me there shouldn't be. If there is a risk then wouldn't that risk already exist regardless of using @Html.Raw
in that modern browsers such as Chrome will allow an edit injection of <script>malicious()</script>
or even to change a form's post action to something else.
相关问题
- Entity Framework throws exception - Network Relate
- Slow loading first page - ASP.NET MVC
- TextBoxFor decimal
- How to do an inline style with asp.net mvc 3 razor
- How to access the System.ComponentModel.DataAnnota
相关文章
- “Dynamic operations can only be performed in homog
- Change color of bars depending on value in Highcha
- How to get server path of physical path ?
- Breakpoint in ASP.NET MVC Razor view will not be h
- How to define function that returns html in asp.ne
- How to find the exceptions / errors when TryUpdate
- ASP.Net MVC 3: optgroup support in Html.DropDownLi
- A circular reference was detected while serializin
@Html.Raw
will allow executing any script that is on the value to display. If you want to prevent that you need to use@Html.AttributeEncode
Correct, the risk is in how it is used. There's no risk inherent in
Html.Raw
. It's a tool, nothing more.If you are displaying user entered information it is better to use @Html.Encode().
In another words, if you are
displaying non-user eneterd data
you are safe to go with @Html.Raw()