A set of technologies in .NET for building web applications and web services. Miscellaneous topics that do not fit into specific categories.
What is the simplest way to implement the same functionality in an asp.net Webform without too much modification?
Simple is in the eye of the developer.
One option is writing a JavaScript/jQuery script to URI encode the text inputs before the inputs are submitted. Decode the inputs on the server. You still need to be careful of the input values so you don't end up with a cross site script vulnerability.
$('form').submit(function(e) {
$('.SpecialChars').each(function (index, element) {
element.value = encodeURI(element.value);
});
});
I used a css class to identify the input to encode.
<asp:TextBox ID="SpecialChars" runat="server" CssClass="SpecialChars"></asp:TextBox>
The code behind
Literal1.Text = Server.UrlDecode(SpecialChars.Text);
I'm not sure if encodeURI will handle ever possible situation. Another option is following the recommendations in the error. Disable request validation and write custom validation which sorta' like the inverse of the the option above. In either case some form of validation logic is needed.