当前位置:编程学习 > C#/ASP.NET >>

ASP翻译成ASP.net

Function PostXmlWebOnline(paraXmlStr)
    On Error Resume Next
    Set objDom = CreateObject("Microsoft.XMLDOM")
    objDom.async = False
    objDom.loadXML paraXmlStr

    '判断XML数据是否装载成功
    If objDom.parseError.errorCode <> 0 Then
             tempErrorStr = objDom.parseError.reason
              PostXmlWebOnline = Replace(resXmlDataStr, tempReplaceStr, tempErrorStr)
              Exit Function
    Else
      Dim strURL
            Set http1 = CreateObject("Microsoft.XMLHTTP")
            strURL = "https://interface.gta-travel.com/gtaapi/RequestListenerServlet"
            http1.Open "Post", strURL, False
            http1.send objDom
            If http1.readyState <> 4 Or http1.Status = "404" Then
                tempErrorStr = "无法找到指定资源"
                PostXmlWebOnline = Replace(resXmlDataStr, tempReplaceStr, tempErrorStr)
                Exit Function
            End If

            resXmlDataStr = CStr(http1.responseText)
            Set http1 = Nothing
            PostXmlWebOnline = resXmlDataStr
   End If
End Function


那位可以帮我把这个段代码翻译成ASP.net,尤其是泛红部分,我不理解
谢谢了 --------------------编程问答-------------------- WebClient webClient=new WebClient(url);
webClient.DownloadString... --------------------编程问答-------------------- 不翻译了,给一个asp.net取html的方法你.
        
        /// <summary>
        /// 以POST方式抓取远程页面内容
        /// </summary>
        /// <param name="url"></param>
        /// <param name="postData">参数列表</param>
        /// <param name="encodeType"></param>
        /// <param name="err"></param>
        /// <returns></returns>
        public static string Post(string url, string postData, Encoding encoding)
        {
            try
            {
                HttpWebRequest request;
                HttpWebResponse response;

                string strResult = "";
                UTF8Encoding encodedData = new UTF8Encoding();
                byte[] byteArray = encodedData.GetBytes(postData);

                request = (HttpWebRequest)WebRequest.Create(url);
                request.Timeout = _iSetTimeOut;
                request.ReadWriteTimeout = _iSetTimeOut;
                request.ServicePoint.Expect100Continue = false;
                request.ServicePoint.UseNagleAlgorithm = false;

                request.Method = "POST";
                request.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
                request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)";
                request.ContentType = "application/x-www-form-urlencoded;";
                request.ContentLength = byteArray.Length;

                Stream newStream = request.GetRequestStream();
                newStream.Write(byteArray, 0, byteArray.Length);
                newStream.Close();

                response = (HttpWebResponse)request.GetResponse();
                StreamReader sr = new StreamReader(response.GetResponseStream(), encoding);
                StringBuilder sb = new StringBuilder();
                sb.Append(sr.ReadToEnd());
                //while (!sr.EndOfStream)
                //{
                //    sb.Append(sr.ReadLine() + "\r\n");
                //}
                strResult = sb.ToString();

                response.Close();
                request = null;
                return strResult;
            }
            catch (WebException ex) { return ""; }
            catch (System.Net.Sockets.SocketException ex) { return ""; }
        }

--------------------编程问答-------------------- --------------------编程问答-------------------- --------------------编程问答--------------------
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,