"Sys.WebForms.PageRequestManagerServerErrorException: status code: 500"
I am using an asp.net text box inside ajax update panel. If I enter &# in the textbox and press Save Button , it giv开发者_如何转开发es 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:
- Validate the contents of the textbox and replace any potentially dangerous (HTML like) values.
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.
精彩评论