Saturday, March 24, 2012

AJAX throw a "Sys.WebForms.PageRequestManagerErrorException" with Server.Transfer

Hi,

First, I′m from Brazil and I don′t know to write English very well, but try show my problem.

I have an application ASP NET AJAX 1.0 with 2 pages in diferent folders, how show the schemma:

Folder 1HomeFolder 2PageWithUpdatePanel

PageWithUpdatePanel contains a UpdatePanel with a Button Control named Button1.

When Home calls PageWithUpdatePanel with Server.Transfer, an error happens in browser when Button1 is pressed in a second time. Any Control causes the exception.

Details from exception message:

Sys.WebForms.PageRequestManagerErrorException: unknown error ocurred while processing the request on the server. The status code returned from the server was: 404

Another message happens with DropDownList:

Sys.WebForms.PageRequestManagerErrorException: The message received from the server cound not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. Details: Error parsing near '<html xmlns="htt'.

I read that "ScriptManager1.RegisterPostBackControl(Button1)" resolves the problem. But is the same that don′t uses Ajax. That result isn′t satisfactory.

With ATLAS the error don′t happens.

The Microsoft Support has resolved the question. Past the Code after UpdatePanel: function EndRequestHandler() { theForm.action = "../NewFolder1/Default.aspx"; theForm._initialAction = theForm.action; } if( typeof(Sys) != "undefined" ) { EndRequestHandler(); Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); }

I have the same issue but I wasn't able to translate the solution from the answer above. Can somebody translate the above answer into VB?

Thank you.


The code is to place in HTML Markup, not in Code-behind. Is JavaScript. The code, with line-breaks is:

function EndRequestHandler()
{
theForm.action = "../NewFolder1/Default.aspx";
theForm._initialAction = theForm.action;
}
if( typeof(Sys) != "undefined" )
{
EndRequestHandler();
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}


Hellooo, I Have the same problem with you, can you help me how to resolve them.

where i can put that code ? can you give me the full source code ?

Thanx And Sorry My English so badBig Smile


No problem, I don′t speak English so mutch too. About the code, you have to place it in HTML markup, after the end tag of UpdatePanel.


I was trying to execute the Server.Transfer([myASPXpage]) inside the click event for my Save button. There were a couple posts on the WEB that poo pooed the idea of using Server.Transfer() in general but for my scenario it ( I thought) was necessary. After the user saved their information I wanted to return them to the main page. On the main page I was using the Request object to verify if the user was coming from a valid URI (make sure the user was signed in). Using Response.Redirect was not helpful because there wasn't a PreviousPage object to check (as there would have been if Server.Transfer was available).

In the end the solution was simple, I had overthunk the scenario by a mile. On my main page I utilized the User object checking the identity to verify that the user was signed in and valid.

Hope that makes sense...

No comments:

Post a Comment