I am using an asp.net text box inside ajax update panel. If I enter &# in the textbox and press Save Button , it gives a javascript error
Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
Please help me why this error appears?
Probably ASP.NET Request Validation kicked in and detected a potentially dangerous request (the &# in the textbox value). This causes an HttpRequestValidationException
to be thrown - hence the 500 HTTP code is returned by the UpdatePanel. The way I see it there are two ways to solve this problem:
Disable request validation:
<%@ Page ValidateRequest="false" %>
If you choose to disable request validation make sure that the value of this textbox is not output verbatim somewhere else in your application. Make sure you are using HttpUtility.HtmlEncode when displaying it in order to avoid XSS issues.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With