PageRequestManagerServerErrorException (status code 500)

In a quick AJAX demo I had to create today, I ran into a (somewhat cryptic) PageRequestManagerServerErrorException. I needed a simple form of the Cascading Dropdown, one that doesn't use a (web)service for its data, but gets it from a simple method. Here's the setup, and the cause...

Lets start with the exact error message:
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500

I needed 2 DropDownLists working together to enable users to first select a month, and then select a day. Of course, you want the second DropDownList to only display days available for the chosen month. Because of that I had two dropdownlists in an updatepanel, and set the first one to AutoPostback so it would trigger the updatepanel. The first one had items set to something like this: <select item>, January, February, March, and so on. The second one got its items from a method, based on the selected value in the first. This worked like a charm, and all was well. When I wanted to check every scenario, I found that selecting <select item> didn't clear DropDownList2 like I coded it to, but it threw the Exception. What caused this?

When setting items throught the IDE, this HTML is generated:

<asp:ListItem>&lt;select item&gt;</asp:ListItem>
<asp:ListItem>First item</asp:ListItem>
<asp:ListItem>Second one</asp:ListItem>

Because the value property for the items wasn't set explicitly, it is generated (or should we say substracted?) from the information that was entered. Therefore, the Value property of the first item was '<select item>'. I can imagine how something like that can mess up a JavaScript environment. ;) I opened up the items for the first DropDownList, and set the value properties for each item explicitly (although setting it to a decent value for the first item did the trick). That resulted in this HTML:

<asp:ListItem Value="0">&lt;select item&gt;</asp:ListItem>
<asp:ListItem Value="1">First item</asp:ListItem>
<asp:ListItem Value="2">Second one</asp:ListItem>

Notice the Value attribute in the ListItem tag? That's the one that will keep your project from throwing a PageRequestManagerServerErrorException.

Published Wed, Feb 20 2008 8:02 PM by Rick van den Bosch
Filed under: , ,

Comments

# asp.net

Pingback from  asp.net

Friday, March 07, 2008 4:42 PM by asp.net

# re: PageRequestManagerServerErrorException (status code 500)

Hi,

I am facing the Same error can you tell me the soultion for this.as i cannot hardcode my values in the dropdownlist it seems to be preety big problem.aslo i am facing the situation which is even more worse.actually my code is working fine on my local systembut when i deployed the code on the Server the error occurs i could not able to track the reason for it until now..Can anyone help me.??

Tuesday, May 20, 2008 9:19 AM by DotnetLover

# re: PageRequestManagerServerErrorException (status code 500)

Caused by the html closing tag (forward slash /), Try escaping it

Wednesday, June 04, 2008 6:18 PM by MW

# re: PageRequestManagerServerErrorException (status code 500)

Can you post a sample of your code. How to use the CascadingDropdown without the Webservice but a method instead. What entries do you use for ServicePath and Category.

thanks,

Saturday, June 28, 2008 3:25 AM by Dave

# re: PageRequestManagerServerErrorException (status code 500)

U can avoid these kind of error by setting validateRequest="false" in the <%@ Page dirctive........ :)

Regards,

Tuesday, September 02, 2008 8:02 AM by Mohamed ghouse

# re: PageRequestManagerServerErrorException (status code 500)

hello everyone,

Problem with Ajax Enabled Application running at server as whenever i leave the page(startup page) for few minutes and then if try to login it shows popup window with below message so i m in great problem so  pls provide me solution for this.

"Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server.  The status code returned from the server was: 500

Saturday, November 15, 2008 8:54 AM by Aravind

# re: PageRequestManagerServerErrorException (status code 500)

you need to do custom error handling to handle such type of error.

In the "EndRequestHandler" just add the following code.

 if (args.get_error() != undefined)

 {

   // If there is, show the custom error.

   $get('Error').style.visibility = "visible";

   // Let the framework know that the error is handled,

   //  so it doesn't throw the JavaScript alert.

   args.set_errorHandled(true);

 }

Tuesday, December 23, 2008 12:55 PM by Yogesh

# re: PageRequestManagerServerErrorException (status code 500)

Is EndRequestHandler functions or what?

And where can I find it?

Please a details for bottom code?

Thanksyou

Thursday, May 07, 2009 12:17 AM by Where is EndRequestHandler???

# re: PageRequestManagerServerErrorException (status code 500)

Set page directive attribute ValidateRequest="false" it will solve problem

Friday, May 22, 2009 8:27 AM by Aswattha

# re: PageRequestManagerServerErrorException (status code 500)

find below code to get EndRequestHandler event....

function EndRequestHandler(sender, args) {

  if (args.get_error() != undefined)

  {  

       args.set_errorHandled(true);

       alert("There was an error" + args.get_error().message);

          }      

}

function load() {

  Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

}

call load() method on your body Onload Event.

Saturday, June 06, 2009 12:03 PM by Jatin Prajapati

# re: PageRequestManagerServerErrorException (status code 500)

Unpleasant one.

Wednesday, September 16, 2009 8:07 AM by Stan

# re: PageRequestManagerServerErrorException (status code 500)

Setting validateRequest=false is not only a bad idea, it's opening you up for a script injection attack:

See this article:

www.asp.net/.../request-validation

Thursday, October 15, 2009 7:39 PM by Simon

# re: PageRequestManagerServerErrorException (status code 500)

set on aspx page validaterequeset=false

Tuesday, October 20, 2009 7:57 PM by Shashi

# re: PageRequestManagerServerErrorException (status code 500)

the problem is due to html tags.

setting ValidateRequest="false" in page directive works fine.

Tuesday, December 29, 2009 5:47 PM by Suraj Shrestha

# Thanks a lot!

thanks a lot, that's exactly what I have been fighting with - "<>" in ListItem's name and setting no explicit value caused this exception!

Wednesday, April 07, 2010 7:17 PM by a

# re: PageRequestManagerServerErrorException (status code 500)

if it helps ... validateRequest="false" DID NOT resolve the problem for me.

I had to remove the <asp:UpdatePanel> code to figure out what the issue was!

I had a <New> as a textvalue in my dropdown which I was inserting for a blank value and that wascausing the issue. Changed this to [NEW] and everything is hunky dory! :P

Wednesday, June 23, 2010 10:25 PM by Abe

# re: PageRequestManagerServerErrorException (status code 500)

Thank You

Friday, July 09, 2010 6:01 PM by Jean Claude

# re: PageRequestManagerServerErrorException (status code 500)

This exception can also be thrown if you have session state set to one of the out-of-proc modes (state server or sql server) and you have an object in session that is not marked as [Serializable].

Monday, August 02, 2010 7:19 AM by Dan Davis

# re: PageRequestManagerServerErrorException (status code 500)

it works fine if you set vaidaterequest="false".Thanks for the help.

Monday, August 09, 2010 10:41 AM by santosh

# re: PageRequestManagerServerErrorException (status code 500)

Thanks a lot.  This post helped me a lot after spending the whole day trying to debug my code.

Monday, September 20, 2010 7:30 PM by Max

# re: PageRequestManagerServerErrorException (status code 500)

I tried to use the solution below and work fine:

<b style="color:red">Set page directive attribute ValidateRequest="false" it will solve problem

</b>

Wednesday, September 22, 2010 8:30 PM by Muhammad

# re: PageRequestManagerServerErrorException (status code 500)

setting page directive attribute ValidateRequest="false" is not working in my case .. i m have deployment my application on windows server 2003 ... any help is appreciated

Thursday, October 28, 2010 9:27 AM by kavit

# re: PageRequestManagerServerErrorException (status code 500)

I was getting the same error.  In the code behind, I had assigned the following text value to a readonly textbox

   Password.Text = "<created by system>"

When I removed the "<" and ">" from the value I assigned to the textbox, I no longer received the 500 error.

Monday, November 08, 2010 1:02 AM by Sean

# re: PageRequestManagerServerErrorException (status code 500)

I had this kind of problem. The way I solved it was by changing the class names in the code behind. Thepage causing problem was test.aspx, but the partial classes in the code behind were named test1. When I was debugging the error, I saw that the javascript was looking for a class named 'test' but it wasn't finding because there wasn't one. So I changed the names of the partial classes to 'test' and it worked.

Friday, November 12, 2010 6:56 PM by DaniBoh

# re: PageRequestManagerServerErrorException (status code 500)

KUDOS to all who have suggested fixes for this! My hero of the day is Dan Davis for his suggestion. I got this error out of a RadGrid while trying to update a business object stored in Session. Temporarily switching my environment back to InProc session state mode, my app works again, so I know I simply have a property that is not serializing.

Thursday, January 06, 2011 7:17 PM by Dylan Baxter

# re: PageRequestManagerServerErrorException (status code 500)

Thanks, I could solve my problem, after ref the content.

Friday, January 21, 2011 4:17 AM by srigurusankar

# re: PageRequestManagerServerErrorException (status code 500)

yes tried validateRequest="false" and it works:D

Wednesday, March 30, 2011 11:28 AM by smaa

Leave a Comment

(required) 
(required) 
(optional)
(required) 
Please add 1 and 1 and type the answer here: