After installning beta 1 I get the following error when an updatepanel updates.
Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed
I live in sweden and make use of the characters å ä ö in text on the website. I think this error have something to do with that, but I'm not sure. It worked fine in the July CTP.
if i'm not mistaken, the | char is used as a separator but it shouldn't be any problem witht it. can you post a simple page that reproduces the problem?
--
Regards,
Luis Abreu
email: labreu_at_gmail.com
EN blog:http://msmvps.com/blogs/luisabreu
I'm developing in a content management system (CMS) called EPIServer, therefore I cannot post all code here. The problem only occur on pages in the CMS system. When I place the code in a seperate file with no CMS it works fine. Maybe you cannot help me because
I'm using this CMS system, but it worked very well in the July CTP, so there must have been some changes with the parser or what is being sent in the xml.
I'm developing in a content management system (CMS) called EPIServer, therefore I cannot post all code here. The problem only occur on pages in the CMS system. When I place the code in a seperate file with no CMS it works fine. Maybe you cannot help me because
I'm using this CMS system, but it worked very well in the July CTP, so there must have been some changes with the parser or what is being sent in the xml.
The code is the following (whatever I update I get the same error)
hum...that seems like normal code to me. btw, maybe you should use fiddler or another http proxy to get the response being sent back from the server. putting it here may help understanding your error...
--
Regards,
Luis Abreu
email: labreu_at_gmail.com
EN blog:http://msmvps.com/blogs/luisabreu
I had a similar error that took me like 4 hours to track down. It turned out that someone had stuck a Response.Write line into one of the UserControls on the page. Hope that helps!
I reproduced the error using the snippet you provided. However, on my site I am using the Blowery HTTP compression module to compress pages. To resolve the problem, I had to disable compression on the page containing this code using the <excludedPaths> element
in the web.config.
I have found out what the problem is but I can't solve it. Maybe someone here can help me.
I have used fiddler to see what goes wrong. The problem is that our CMS system changes the form action attribute of the aspnet tag <form> on the page when it loads. This is done by a javascript in <head>. This is done to be able to use postbacks on friendly
URLs. The form action is set to "/MyPage/Post.aspx e.g. The Post.aspx handles the postbacks correctly. When they did this solution they only thought of usual postbacks not partial ones.
Ok, the postback for my updatepanel works well the first time because of that the form action is set to Post.aspx. But when the partial postback is executed something changes the form action to the right path of the page. Therefore the next partial postback
will not work, because the form action is not set to .../Post.aspx. I have figured out that asp.net AJAX does this change of the form action. it comes from the end of the httpmessage, namely: |formAction||../../templates/Page.aspx?id=30&epslanguage=EN|. This
should be something like: |formAction||/Page/Post.aspx|.
I have found out two solutions, but don't know how to implement them:
1. Change the httprequest formAction in some way
2. Add a javascript that changes the form action everytime a partial postback is done.
I had the same problem (AJAX + url rewriting) and I implemented a simple response filter:
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Web;
public class AjaxPageFilter : Stream
{
Stream responseStream;
long position;
StringBuilder responseHtml;
public AjaxPageFilter(Stream inputStream)
{
responseStream = inputStream;
responseHtml = new StringBuilder ();
}
public override bool CanRead
{
get { return true;}
}
public override bool CanSeek
{
get { return true; }
}
public override bool CanWrite
{
get { return true; }
}
public override void Close()
{
responseStream.Close ();
}
public override void Flush()
{
responseStream.Flush ();
}
public override long Length
{
get { return 0; }
}
public override long Position
{
get { return position; }
set { position = value; }
}
public override long Seek(long offset, SeekOrigin origin)
{
return responseStream.Seek (offset, origin);
}
public override void SetLength(long length)
{
responseStream.SetLength (length);
}
public override int Read(byte[] buffer, int offset, int count)
{
return responseStream.Read (buffer, offset, count);
}
public override void Write(byte[] buffer, int offset, int count)
{
string finalHtml = System.Text.UTF8Encoding.UTF8.GetString(buffer, offset, count);
// Transform the response
string formAction = Util.OriginalRequestUrl;
if (!String.IsNullOrEmpty(formAction))
{
finalHtml = Regex.Replace(finalHtml, "\\|\\d+\\|formAction\\|\\|[^\\|]+\\|",
"|" + formAction.Length.ToString() + "|formAction||" + formAction + "|",
RegexOptions.IgnoreCase);
}
// Write the response
byte[] data = System.Text.UTF8Encoding.UTF8.GetBytes(finalHtml);
responseStream.Write(data, 0, data.Length);
}
}
You should replace "Util.OriginalRequestUrl" with your code.
This filter can be attached in some HttpModule for example like this:
public class UrlRewriter : IHttpModule
{
public UrlRewriter()
{
}
public void Dispose()
{
}
public void Init(HttpApplication application)
{
application.BeginRequest += new EventHandler(application_BeginRequest);
application.ReleaseRequestState += new EventHandler(InstallResponseFilter);
}
void application_BeginRequest(object sender, EventArgs e)
{
HttpContext context = HttpContext.Current;
// original URLstring url = context.Server.UrlDecode(context.Request.Url.ToString());
// store original URL
Util.OriginalRequestUrl = url;
// ...
}
private void InstallResponseFilter(object sender, EventArgs e)
{
HttpResponse response = HttpContext.Current.Response;
if (response.ContentType == "text/plain")
response.Filter = new AjaxPageFilter(response.Filter);
}
}
Hope that helps.
Feodor Fitsner, MCSD
CEO, DotNetPanel Company
DotNetPanel - Secure and Scalable Hosting Management Solution
http://www.dotnetpanel.com
erzki
Member
72 Points
26 Posts
The message received from the server could not be parsed
Oct 23, 2006 12:42 PM|LINK
After installning beta 1 I get the following error when an updatepanel updates.
Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed
I live in sweden and make use of the characters å ä ö in text on the website. I think this error have something to do with that, but I'm not sure. It worked fine in the July CTP.
erzki
Member
72 Points
26 Posts
Re: The message received from the server could not be parsed
Oct 23, 2006 01:45 PM|LINK
I figured out that it does not depend on the å ä ö characters.
It works well to update the updatepanel once. But when I update it a second time I get the above error. I have no idea what is wrong.
What parts is sent int the xml between server and client? <head> etc.. It must be a illegal charcter somewhere in the second postback.
Luis Abreu
All-Star
25674 Points
5369 Posts
MVP
Re: The message received from the server could not be parsed
Oct 23, 2006 02:18 PM|LINK
hello.
if i'm not mistaken, the | char is used as a separator but it shouldn't be any problem witht it. can you post a simple page that reproduces the problem?
Regards,
Luis Abreu
email: labreu_at_gmail.com
EN blog:http://msmvps.com/blogs/luisabreu
erzki
Member
72 Points
26 Posts
Re: The message received from the server could not be parsed
Oct 23, 2006 02:38 PM|LINK
I'm developing in a content management system (CMS) called EPIServer, therefore I cannot post all code here. The problem only occur on pages in the CMS system. When I place the code in a seperate file with no CMS it works fine. Maybe you cannot help me because I'm using this CMS system, but it worked very well in the July CTP, so there must have been some changes with the parser or what is being sent in the xml.
The
erzki
Member
72 Points
26 Posts
Re: The message received from the server could not be parsed
Oct 23, 2006 02:41 PM|LINK
I'm developing in a content management system (CMS) called EPIServer, therefore I cannot post all code here. The problem only occur on pages in the CMS system. When I place the code in a seperate file with no CMS it works fine. Maybe you cannot help me because I'm using this CMS system, but it worked very well in the July CTP, so there must have been some changes with the parser or what is being sent in the xml.
The code is the following (whatever I update I get the same error)
<atlas:UpdatePanel runat="server" id="UpdatePanel1" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label runat="server" ID="Label1"></asp:Label><br />
</ContentTemplate>
<Triggers>
<atlas:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</atlas:UpdatePanel>
<asp:TextBox runat="server" ID="TextBox1"></asp:TextBox><asp:Button runat="server" ID="Button1" Text="Update"/><br />
<asp:Button runat="server" ID="ButtonSend" Text="Send" /><br />
<asp:Label runat="server" ID="LabelID"></asp:Label>
Luis Abreu
All-Star
25674 Points
5369 Posts
MVP
Re: The message received from the server could not be parsed
Oct 23, 2006 05:51 PM|LINK
hello again.
hum...that seems like normal code to me. btw, maybe you should use fiddler or another http proxy to get the response being sent back from the server. putting it here may help understanding your error...
Regards,
Luis Abreu
email: labreu_at_gmail.com
EN blog:http://msmvps.com/blogs/luisabreu
mhil_cbtech
Member
82 Points
26 Posts
Re: The message received from the server could not be parsed
Oct 25, 2006 01:40 PM|LINK
I had a similar error that took me like 4 hours to track down. It turned out that someone had stuck a Response.Write line into one of the UserControls on the page. Hope that helps!
Mark
lodestar
Member
30 Points
6 Posts
Re: The message received from the server could not be parsed
Oct 25, 2006 06:47 PM|LINK
I reproduced the error using the snippet you provided. However, on my site I am using the Blowery HTTP compression module to compress pages. To resolve the problem, I had to disable compression on the page containing this code using the <excludedPaths> element in the web.config.
erzki
Member
72 Points
26 Posts
Re: The message received from the server could not be parsed
Nov 07, 2006 02:48 PM|LINK
I have found out what the problem is but I can't solve it. Maybe someone here can help me.
I have used fiddler to see what goes wrong. The problem is that our CMS system changes the form action attribute of the aspnet tag <form> on the page when it loads. This is done by a javascript in <head>. This is done to be able to use postbacks on friendly URLs. The form action is set to "/MyPage/Post.aspx e.g. The Post.aspx handles the postbacks correctly. When they did this solution they only thought of usual postbacks not partial ones.
Ok, the postback for my updatepanel works well the first time because of that the form action is set to Post.aspx. But when the partial postback is executed something changes the form action to the right path of the page. Therefore the next partial postback will not work, because the form action is not set to .../Post.aspx. I have figured out that asp.net AJAX does this change of the form action. it comes from the end of the httpmessage, namely: |formAction||../../templates/Page.aspx?id=30&epslanguage=EN|. This should be something like: |formAction||/Page/Post.aspx|.
I have found out two solutions, but don't know how to implement them:
1. Change the httprequest formAction in some way
2. Add a javascript that changes the form action everytime a partial postback is done.
Does anyone here know how to perform 1. or 2.?
Thanks
fitsner
Member
160 Points
32 Posts
Re: The message received from the server could not be parsed
Nov 07, 2006 06:31 PM|LINK
Hi,
I had the same problem (AJAX + url rewriting) and I implemented a simple response filter:
using System; using System.Text; using System.Text.RegularExpressions; using System.IO; using System.Web; public class AjaxPageFilter : Stream { Stream responseStream; long position; StringBuilder responseHtml; public AjaxPageFilter(Stream inputStream) { responseStream = inputStream; responseHtml = new StringBuilder (); } public override bool CanRead { get { return true;} } public override bool CanSeek { get { return true; } } public override bool CanWrite { get { return true; } } public override void Close() { responseStream.Close (); } public override void Flush() { responseStream.Flush (); } public override long Length { get { return 0; } } public override long Position { get { return position; } set { position = value; } } public override long Seek(long offset, SeekOrigin origin) { return responseStream.Seek (offset, origin); } public override void SetLength(long length) { responseStream.SetLength (length); } public override int Read(byte[] buffer, int offset, int count) { return responseStream.Read (buffer, offset, count); } public override void Write(byte[] buffer, int offset, int count) { string finalHtml = System.Text.UTF8Encoding.UTF8.GetString(buffer, offset, count); // Transform the response string formAction = Util.OriginalRequestUrl; if (!String.IsNullOrEmpty(formAction)) { finalHtml = Regex.Replace(finalHtml, "\\|\\d+\\|formAction\\|\\|[^\\|]+\\|", "|" + formAction.Length.ToString() + "|formAction||" + formAction + "|", RegexOptions.IgnoreCase); } // Write the response byte[] data = System.Text.UTF8Encoding.UTF8.GetBytes(finalHtml); responseStream.Write(data, 0, data.Length); } }You should replace "Util.OriginalRequestUrl" with your code.
This filter can be attached in some HttpModule for example like this:
Hope that helps.CEO, DotNetPanel Company
DotNetPanel - Secure and Scalable Hosting Management Solution
http://www.dotnetpanel.com