相关疑难解决方法(0)

如何使用C#将JSON发布到服务器?

这是我正在使用的代码:

// create a request
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create(url); request.KeepAlive = false;
request.ProtocolVersion = HttpVersion.Version10;
request.Method = "POST";


// turn our request string into a byte stream
byte[] postBytes = Encoding.UTF8.GetBytes(json);

// this is important - make sure you specify type this way
request.ContentType = "application/json; charset=UTF-8";
request.Accept = "application/json";
request.ContentLength = postBytes.Length;
request.CookieContainer = Cookies;
request.UserAgent = currentUserAgent;
Stream requestStream = request.GetRequestStream();

// now send it
requestStream.Write(postBytes, 0, postBytes.Length);
requestStream.Close();

// grab te response and print it out …
Run Code Online (Sandbox Code Playgroud)

c# post json httpwebrequest

246
推荐指数
10
解决办法
56万
查看次数

C#忽略证书错误?

在对远程Web服务的Web服务请求期间,我收到以下错误:

无法为SSL/TLS安全通道建立信任关系.---> System.Security.Authentication.AuthenticationException:根据验证程序,远程证书无效.

反正有没有忽略这个错误,并继续?

似乎远程证书没有签名.

我连接的网站是www.czebox.cz- 所以随时访问该网站,并注意甚至浏览器抛出安全例外.

.net c# ssl

147
推荐指数
8
解决办法
18万
查看次数

标签 统计

c# ×2

.net ×1

httpwebrequest ×1

json ×1

post ×1

ssl ×1