I work through NerdDinner and I got a little confused in the next section ...
First they added a form to create a new dinner with a bunch of text fields, for example:
<%= Html.TextArea("Description") %>
They then show two ways to bind form input to a model:
[AcceptVerbs(HttpVerbs.Post)] public ActionResult Create() { Dinner dinner = new Dinner(); UpdateModel(dinner); ... }
or
[AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(Dinner dinner) { ... }
Well, great, so far everything looks very simple.
Then a little later they say:
It is important to always be paranoid about security when receiving any user input, and this is also true when binding objects to input input. You should be careful to always HTML code any user-entered values ββto avoid HTML and JavaScript injection attacks
BUT? MVC manages data binding for us. Where / how should you do HTML encoding?
security asp.net-mvc html-encode
fearofawhackplanet
source share