关于The underlying connection was closed

我在做信用卡的连接时发现在如果服务器有防火墙就会有这样的问题.只要把WebRequest的地址叫网络管理员加入到系统的网络防火墙就行了.

string result = ""
string strPost = 
"x_login=YOUR-LOG-IN-ID&x_tran_key=YOUR-TRANSACTION-KEY&x_method=CC&x_type=AUTH_CAPTURE&x_amount=1.00&x_delim_data=TRUE&x_delim_char=|&x_relay_response=FALSE&x_card_num=4111111111111111&x_exp_date=052005&x_test_request=TRUE&x_version=3.1"




// Create a new request to the mentioned URL. 
HttpWebRequest objRequest = 
(HttpWebRequest)WebRequest.Create(
"https://certification.authorize.net/gateway/transact.dll"); 


// objRequest.Proxy= new WebProxy("8.3.8.101"); 
objRequest.Method = "POST"
objRequest.ContentLength 
= strPost.Length; 
objRequest.ContentType 
= "application/x-www-form-urlencoded"

string error=""
StreamWriter myWriter 
= null
// try 
// { 
myWriter = new StreamWriter(objRequest.GetRequestStream()); 
myWriter.Write(strPost); 
// } 
// catch (Exception ex) 
// { 
// error=ex.Message; 
// } 
// finally 
// { 
myWriter.Close(); 
// } 
posted on 2005-05-17 09:50  microtea  阅读(3231)  评论(0编辑  收藏  举报