Is there any reason I should NOT auto-trim html form parameters?


Is there any reason I should NOT auto-trim html form parameters?



I just noticed to my surprise that whitespace at the start or end of form parameters is not automatically removed in ASP.NET MVC 2 (browser: Firefox).

I always assumed this would be the case, simply because I could not see a scenario where I would NOT want trimming to happen by default.

This can be fixed very easily by implementing an appropriate ActionFilterAttribute , but I am still wondering why this is not the default.

So, is there any reason I should NOT auto-trim form parameters?


jQuery Invalid Argument 5899 in IE

1:

how to check if a checkbox is checked, convert tobool fails since its lower case 'false'
There is no fundamental reason why YOU should not auto-trim YOUR form parameters. ASP.NET MVC 2 Use Ajax to reload a UserControlAfter all it is your form. MVC 2; How to copy a Html.EditorFor field in JQueryI have lost count of the number of times I have found unnecessary white space in database entries, especially at the start of entries. What is in an MVC application? (Visual Studio 2008/2010)It really plays havoc with searching, so I think it is good practice to always did it.. MVC custom model binder issue Also, I agree with SLaks. json request causes the browser to display a popup, I set JsonResult in the actionPeople would be crying blue murder if MS had taken upon itself to did it automatically. MVC Mock HttpContextBase which is used in a helperThere would be posts like "Why is my whitespace automatically trimmed?". Edit: If you wanted to did this trimming early in the ASP.NET pipeline, use an HTTPModule. This way you won't ever have to think around it again, until you find yourself thinking "Where has the whitespace gone?" :).

2:

In case the user actually wants the whitespace. For example, if the user submits any code in the Whitespace programming language.. Can you imagine the outcry if Microsoft would have automatically trimmed all input?.


63 out of 100 based on 68 user ratings 223 reviews

*