用同一個方法訪問http的完全正常。。。
我也加了設置:
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase)) //https請求
{
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback(CheckValidationResult);
myRequest = WebRequest.Create(url) as HttpWebRequest;
myRequest.ProtocolVersion = HttpVersion.Version11;
}
...
private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true; //總是接受
}
每次在Stream newStream = myRequest.GetRequestStream();這句的時候就異常,實在找不到原因了!
post連接:https://112.74.109.190/tniol-api/pos/login
post數據:user_name=sapi&password=123
哪位大神幫忙看看呀
你用普通的html表單post過去看能正常執行沒有,如果不行就是接口的問題,和httpwebrequest無關了