I'm coding a script that will submit a form for a user on server side. The form handling script was designed to take both post information and querystring information. I have no control over how the form handling script runs. One of the querystring items is a url which must be escaped. Problem is when I escape it and make a Request object it is magically unescaped (checked by printing the Request.Address). I've tried doubly escaping the item and it is not unescaped at all then (still doubly escaped).
I've also tried the new Uri(String Uri, Boolean escaped) constructor which has the same effect.
Any ideas?
Code:
//Make new account web request.
String sPost = "name=value";
byte[] aPostData = Encoding.UTF8.GetBytes(sPost);
HttpWebRequest oReq = (HttpWebRequest)WebRequest.Create(new Uri(" + Server.UrlEncode(" + sPMID + "[pmid]&db=pubmed&dispmax=50&doptcmdl=medline"),true));
oReq.Method = "POST";
oReq.ContentType = "application/x- oReq.ContentLength = aPostData.Length;
Stream oDataStream = oReq.GetRequestStream();
oDataStream.Write(aPostData, 0, aPostData.Length);
oDataStream.Flush();
oDataStream.Close();
I've also tried the new Uri(String Uri, Boolean escaped) constructor which has the same effect.
Any ideas?
Code:
//Make new account web request.
String sPost = "name=value";
byte[] aPostData = Encoding.UTF8.GetBytes(sPost);
HttpWebRequest oReq = (HttpWebRequest)WebRequest.Create(new Uri(" + Server.UrlEncode(" + sPMID + "[pmid]&db=pubmed&dispmax=50&doptcmdl=medline"),true));
oReq.Method = "POST";
oReq.ContentType = "application/x- oReq.ContentLength = aPostData.Length;
Stream oDataStream = oReq.GetRequestStream();
oDataStream.Write(aPostData, 0, aPostData.Length);
oDataStream.Flush();
oDataStream.Close();