This is a migrated thread and some comments may be shown as answers.

Encoding bug in Ajax Request

2 Answers 53 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 21 Mar 2009, 12:08 AM
There seems to be a problem with request encoding.
when sending back a textbox value containing a "<" followed by a caracter via ajax, a 500
server erros is returned.
the issue can be reproduced with your Ajax/Form Values demo:
just enter someting like "<abcd" into the name box and try to save.

regards,
peter

2 Answers, 1 is accepted

Sort by
0
SamJ
Top achievements
Rank 1
answered on 22 Mar 2009, 12:07 AM
Hi Peter,

I am not sure if this an issue with ajax. This is replicable in a simple page with a TextBox and a Button controls:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server"
    <div> 
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
        <asp:Button ID="Button2" runat="server" Text="Button" /> 
    </div> 
    </form> 
</body> 
</html> 

After submitting you should receive:
"A potentially dangerous Request.Form value was detected from the client (TextBox1="<abcd")." error.

Check it out.

SamJ
0
Peter
Top achievements
Rank 1
answered on 22 Mar 2009, 10:07 AM
You are right, the http:500 is returned from the page validation. It's tricky to find out with an ajax request because you just get a stupid javascript error.  Setting validateRequest to false in web.config  fixes the problem.

thanks,
peter
Tags
Ajax
Asked by
Peter
Top achievements
Rank 1
Answers by
SamJ
Top achievements
Rank 1
Peter
Top achievements
Rank 1
Share this question
or