如何将下面2个java的webhttp代码转换成c#代码?
String login(String IPADDR, String pwd, String usrname)
throws URISyntaxException, ClientProtocolException, IOException {
HttpUriRequest lg= RequestBuilder.post()
.setUri(new URI("http://" + IPADDR+ "/main/certificate"))
.addParameter("password", pwd)
.addParameter("username", usrname).build();
CloseableHttpResponse rspne = httpclient.execute(lg);
try {
HttpEntity entity = rspne .getEntity();
String str = EntityUtils.toString(entity);
return str ;
} finally {
rspne .close();
}
}
String addUser(String IPADDR, String username, String pwd)
throws URISyntaxException, ClientProtocolException, IOException {
HttpPost htpPost=new HttpPost("http://" + IPADDR+ "/main/usr/add");
List <BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("username", username));
params.add(new BasicNameValuePair("password", pwd));
post.setEntity(new UrlEncodedFormEntity(params,HTTP.UTF_8));
CloseableHttpResponse respnse = httpclient.execute(htpPost);
try {
HttpEntity entity = respnse .getEntity();
String str = EntityUtils.toString(entity);
return str ;
} finally {
respnse .close();
}
}