c# - Equal sign in data "causes" BeginGetRequeststream to fail -


the line marked in code below (//this async call). not call async call if pass in value query function:

<verb>get</verb><resourcelist><catalogquery><itemquerylist><itemidlist><id>16-=-cedar-bonsai</id></itemidlist><attributestype>all</attributestype></itemquerylist></catalogquery> 

note part of xml:

<id>16-=-cedar-bonsai</id> 

however works if switch equal sign else

<verb>get</verb><resourcelist><catalogquery><itemquerylist><itemidlist><id>16-here-cedar-bonsai</id></itemidlist><attributestype>all</attributestype></itemquerylist></catalogquery> 

whats confusing me contents of query should have absolutly no effect on callback being called. right?

here code

//get item attributes async         public xelement makeasynccall(string query,bool create = false,bool resent = false)         {              manualresetevent mre = null;             //the results stored here;             stringbuilder xresults = new stringbuilder() ;              sem.waitone();             try             {                 query = query.replace("&", "&amp;");                 query = query.replace("#39;", "apos;");                  //if not query being sent again append additional info                 if (!resent)                 {                     query = header_text + query + closer_text;                 }                  //concatonate declaration, header information, query performed, , closing xml tag. convert byte array                 byte[] bytedata = utf8encoding.utf8.getbytes(                             new xdocument(                                 new xdeclaration("1.0", "utf-8", null),                                 xelement.parse(query)                             ).tostring()                 );                  string paddr = post_address_query;                 if (create != false)                 {                     paddr = post_address_creation;                 }                  //setup post connection                  httpwebrequest httpwreq = webrequest.create(paddr) httpwebrequest;                 httpwreq.method = "post";                 httpwreq.contenttype = "application/x-www-form-urlencoded";                 httpwreq.proxy = null;                 httpwreq.contentlength = bytedata.length;                 httpwreq.keepalive = true;                   using (mre = new manualresetevent(false))                 {                        //this async call                      httpwreq.begingetrequeststream(new asynccallback(getrequeststreamasync), tuple.create<httpwebrequest, byte[], bool, stringbuilder, manualresetevent>(httpwreq, bytedata, create, xresults, mre));                     mre.waitone(10000);                     mre.close();                      //try again if not exited already.                     if (xresults.length == 0)                     {                         httpwreq.abort();                         sem.release();                         return makeasynccall(query, create, true);                     }                      sem.release();                     return xelement.parse(xresults.tostring(), loadoptions.preservewhitespace);                  }             }             catch(exception ex)             {                 mre.close();                 sem.release();                 throw (ex);             }         } 

i found out causing issue. callback being executed not causing breakpoints stop. morning tried code again , breakpoints being caught. not sure if bug in visual studio or undefined behavior? maybe else knows more visual studio in regards.

the requests going through fine , receiving responses later in code generating own exceptions, catching them, throwing them, , retrying command. stuck in infinite loop.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -