首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

HttpWebRequest有关问题,请帮个忙,解决有关问题后马上结帐!

2011-12-31 
HttpWebRequest问题,请各位高手帮个忙,解决问题后马上结帐!!!在线等....我想将asp写的一XMLHTTP改写为有as

HttpWebRequest问题,请各位高手帮个忙,解决问题后马上结帐!!!在线等....
我想将asp写的一XMLHTTP改写为有asp.net的HttpWebRequest:
  strURL= "http://www.website-export.com/cgi-bin/cnps.cgi? "&cnpsStr
    Set       WinHttpReq       =   server.CreateObject( "Microsoft.XMLHTTP ")      
   
    WinHttpReq.Open       "GET ",       strURL,       false      
    WinHttpReq.SetRequestHeader   "REMOTE_HOST ",   Request.ServerVariables( "SERVER_NAME ")  
    WinHttpReq.SetRequestHeader   "URL ",     Request.ServerVariables( "URL ")

    WinHttpReq.Send
   
    strResult   =   WinHttpReq.ResponseText
    PostCnpsRequest   =   strResult
改为:
Encoding   encoding   =   Encoding.GetEncoding( "GB2312 ");
string   postData= "user_id= "+ "1485 ";
postData   +=   ( "&origin_zip= "+ "100071 ");
postData+=( "&desti_zip= "+desti_zip);
postData+=( "&shipping_weight= "+shipping_weight);
postData+=( "&shipping_method= "+ "parcel_post ");
string   strUrl   =   "http://www.website-export.com/cgi-bin/cnps.cgi ";

byte[]   data   =   encoding.GetBytes(postData);

//   准备请求...
HttpWebRequest   myRequest   =   (HttpWebRequest)WebRequest.Create(strUrl);
myRequest.Method   =   "POST ";
myRequest.ContentType= "www.car8848.cn/ProductPSFS.aspx ";

myRequest.ContentLength   =   data.Length;

Stream   newStream=myRequest.GetRequestStream();
newStream.Write(data,0,data.Length);
newStream.Close();

WebResponse   response   =   myRequest.GetResponse();

Stream   resStream   =   response.GetResponseStream();
StreamReader   sr   =   new   StreamReader(resStream,   System.Text.Encoding.Default);
Response.Write   (   sr.ReadToEnd());
resStream.Close();  
sr.Close();
其中
WinHttpReq.SetRequestHeader   "REMOTE_HOST ",   Request.ServerVariables( "SERVER_NAME ")  
    WinHttpReq.SetRequestHeader   "URL ",     Request.ServerVariables( "URL ")

这个要如何在asp.net   中表现出来呢?

[解决办法]

[解决办法]
学习ing ..
[解决办法]
myRequest.Headers.Add( "REMOTE_HOST ",
Request.ServerVariables( "SERVER_NAME ") ) ;

myRequest.Headers.Add( "URL ", Request.ServerVariables( "URL ") ) ;

___________


[解决办法]
System.Web.HttpRequest.ServerVariables[ " "]
[解决办法]
全都在这里了:foreach(string key in Request.ServerVariables){Response.Write(key + " = "+ Request.ServerVariables[key] + " <BR> ");}
[解决办法]
顶~~~~~给分

热点排行