Java to c# conversion

  • Thread starter Thread starter K R
  • Start date Start date
K

K R

Hi,

Please let me know the equivalent code to the below code in c#
(ASP.NET).

This below code is written in java.

MyDataString =
#DREDOCID 1
#DREFIELDNAME Price
#DREFIELDVALUE 10
#DREDOCREF http://www.autonomy.com/autonomy/dynamic/autopage442.shtml
#DREFIELDNAME Country
#DREFIELDVALUE UK

SAMPLE CODE

URL suir_url = new URL("http://" +SUIRServer +":" +SUIRPort
+"/DREREPLACE?");
URLConnection suir_connection = suir_url.openConnection();
suir_connection.setDoOutput(true);
PrintWriter suir_out = new
PrintWriter(suir_connection.getOutputStream());
suir_out.println(MyDataString +"#DREENDDATA" +"\n\n"); // PASS data
as POST To Suir
suir_out.close();


Regards.
 
It should be something like:

[ using System, System.IO, System.Net ]
Uri suir_url = new Uri("http://" +SUIRServer +":" +SUIRPort
+"/DREREPLACE?");
HttpWebRequest wr = HttpWebRequest.Create(url);
wr.Method = "POST";
// wr.ContentType = "application/x-www-form-urlencoded";
StreamWriter sw = new StreamWriter(wr.GetRequestStream());
sw.Write(data);
sw.Close();
 
Back
Top