Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"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 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?

enter image description here

like image 941
Basmah Avatar asked Mar 03 '11 08:03

Basmah


1 Answers

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:

  1. Validate the contents of the textbox and replace any potentially dangerous (HTML like) values.
  2. 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.

like image 82
Atanas Korchev Avatar answered Sep 22 '22 19:09

Atanas Korchev