我在做ASP.NET项目的时候,当用到Ajax时,经常会出项会弹出一个对话框,内容如下:
Sys.WebForms.PageRequestManagerParseErrorException:The message received from the server
could not be parsed.Common causes for this error are when the response is modified by calls
Details:Error parsing near'                                 </div>
                                               </html>    
    <head>
, 
 不知道是咋回事儿,还请高手帮忙看!
有的说是只要用到Ajax控件都有这样的错误,特别是用到response对象时,出现频率会多一些!

解决方案 »

  1.   

    我也见过,不过也不怎么会处理,Response.Write("<script></script>");这样用就会错的,如果你自己写Js的话就不会了,
      

  2.   

    自己的写的好像是不报错,但是要达到Ajax扩展控件的效果,要写好多的js
    我刚到网上搜一把,具体如下,明天再去试试看行不行你的代码中没有Respose.Write(),有Session,那就是因为可能Session丢失发出的异常,时有时无. 
    具体分析参考如下(来源网上): 
    ASP.NET中使用AJAX后,Session丢失异常的自定义处理。ASP.NET中使用AJAX后,如果客户端长时间没有操作或者 服务器原因丢失Session,会弹出类似以下的英文错误信息,对于用户没有实际提示作用。为了有更好的用户体验,我们希望能够自 定义这个异常。 
      引用内容Sys.WebForms.PageRequestManagerParserErrorException:   The   message   received   from   the   server   could   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   ' 下面提供一个很简单的办法,使用ScriptManager的EndRequestHandler事件。将以下Javascript加入到 <ScriptManager> 标签后面, 注意不能放在 <Head> 中。 
      程序代码 <script   language= "javascript ">   Sys.WebForms.PageRequestManager.getInstance().add_endRequest (EndRequestHandler);   
    function   EndRequestHandler(sender,   args)   
    {   
    if   (args.get_error()   !=   undefined)   
    {   
    if(args.get_error().message.substring(0,   51)   ==   "Sys.WebForms.PageRequestManagerParserErrorException ")   

    window.location.reload();   //出现Session丢失时的错误处理,可以自己定义。 
    }   
    else 

    alert( "发生错误!原因可能是数据不完整,或网络延迟。 ");   //其他错误的处理。 

    args.set_errorHandled(true);   

    }   
    </script>