How do I read params sent to .aspx from JavaScript with XMLHTTPRequest?

In the client side I'm doing this:

                 var this.rsSyncObject = null;
            if (window.XMLHttpRequest){
                  this.rsSyncObject = new XMLHttpRequest();
            }
            else if (window.ActiveXObject) {
                  this.rsSyncObject = new ActiveXObject('Microsoft.XMLHTTP');
            }

                 this.rsSyncObject.open("POST", "ThePage.aspx", false);      
                 this.rsSyncObject.send("param1=1;param2=2;param3=3;");
                 this.rsResult = this.rsSyncObject.responseText;

And it loads the page and waits for an answer ok, but how do I read the params I sent in the send() function from "ThePage.aspx"?
mak730Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SThorogoodCommented:
Use the Request.Form collection - e.g:

string param1 = Request.Form["param1"];

0
SThorogoodCommented:
Actually, looking again, you have a strange format for the post data. If you use the standard URL encoding - e.g:

param1=1&param2=2 etc. (including encoding special URL chars)

then the Request.Form collection should be populated. Othrewise, you will need to read the Request.InputStream into a strign and split that manually.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mak730Author Commented:
ok, Request.Form doesn't work at all, but the Request.InputStream does, in fact here is a little code to do the job:

                  private Hashtable GetHTTPParams(){
                  //Create a Stream object.
                  Stream str = Request.InputStream;
                  //Find number of bytes in stream and read.
                  int strLen = Convert.ToInt32(str.Length);                  
                  byte [] buff = new byte[strLen];
                  str.Read(buff, 0, strLen);
                  
                  //Convert byte array to a text string.
                  string s = "";
                  for(int i=0; i<strLen; i++)
                        s += Convert.ToChar(buff[i]);

                  //Convert string into a hashtable
                  Hashtable ht = new Hashtable();
                  string []data = s.Split('&');
                  s = "";
                  for(int i=0; i < data.Length; i++){
                        s = data[i];
                        if (s != ""){                              
                              string []elem = s.Split('=');
                              ht.Add(elem[0], elem[1]);
                        }
                  }
                  return ht;                  
            }
0
SThorogoodCommented:
Glad you got it sorted, though the Request.Form method should work. Possibly need to set the ContentType of the Request to:

application/x-www-form-urlencoded

?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.