vaibhavd
vaibhavd

Reputation:

Sys.WebForms.PageRequestManagerServerErrorException

I am using the asp.net with c# and using the update pannel as well as flash control i am getting the error sometime not all time and no page navigate after then plz help me out

following is the massange on the pop up window:-

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

Please Help me out sence may on the demo time the application may carsh

Upvotes: 5

Views: 20712

Answers (3)

Aaron Newton
Aaron Newton

Reputation: 2316

I've managed to generate a similar error with a repeater which used alternating rows where one of the controls was missing from the alternating styles. For example, 'Literal1' was defined in the <ItemTemplate> but not the <AlternatingItemTemplate>. I realize this question has been answered, but hopefully this will save someone some debugging time.

Upvotes: 0

Abdullah
Abdullah

Reputation: 61

What I remember is, this error was occuring in my case when a calendar control was clicked and it posted back to fill value in textbox. This calendar control was in UpdatePanel. During this calendar control post back if I click a button which is not in UpdatePanel (and causes page to post back) then this error occurs.

You can follow this: http://msdn.microsoft.com/en-us/library/bb398934.aspx

By adding this script you can avoid displaying of error.

   <script type="text/javascript" language="javascript">
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
    function EndRequestHandler(sender, args) {
        if (args.get_error() != undefined) {
            var errorMessage;
            if (args.get_response().get_statusCode() == '200') {
                errorMessage = args.get_error().message;
            }
            else {                
                // Error occurred somewhere other than the server page.
                errorMessage = 'An unspecified error occurred. ';                                    
            }
            args.set_errorHandled(true);                
        }
    }
</script>

Upvotes: 6

nickytonline
nickytonline

Reputation: 6981

Error 0 means there was no error. I don't know why it happens, but when it does, I just mark the error as handled and nothing blows up. Just add the following JavaScript and you're troubles will disappear.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <script type="text/javascript" >
        (function() {
            var prm = Sys.WebForms.PageRequestManager.getInstance();

            if (prm)
            {
                prm.add_endRequest(
                function (sender, args) {            
                    // Any code you want here

                    if(args.get_error() && args.get_error().name === 'Sys.WebForms.PageRequestManagerServerErrorException')
                    {
                        args.set_errorHandled(args._error.httpStatusCode == 0);
                    }
                });
            }
        })();
        </script>
    </form>
</body>
</html>

Upvotes: 3

Related Questions