日期:2014-05-17  浏览次数:20449 次

asp.net 模拟post的时候跳转过去的问题.
模拟post的时候能否自动跳转到post页面?.注意是在.CS 模拟post的情况

------解决方案--------------------
我对你这个问题一头雾水。。。

你是想再页面的cs文件创建表单,以post方式提交表单?
------解决方案--------------------
楼主把问题点描述清楚点,这样大家才好进一步帮你解决的。
------解决方案--------------------
/// <summary>
        /// Post数据
        /// </summary>
        private static bool HttpPost(string sUrl, string data, ref string sError)
        {
            string postData = data;
            try
            {
                if (string.IsNullOrEmpty("sUrl")) throw new Exception("URL地址有误");
                //将数据提交到代理
                WebRequest myWebRequest = WebRequest.Create(sUrl);
                myWebRequest.Method = "POST";
                myWebRequest.Timeout = 4000;
                myWebRequest.ContentType = "application/x-www-form-urlencoded";
                Stream streamReq = myWebRequest.GetRequestStream();
                byte[] byteArray = Encoding.GetEncoding("GB2312").GetBytes(postData);
                streamReq.Write(byteArray, 0, byteArray.Length);
                streamReq.Close();

                //获取系统返回的数据
                WebResponse myWebResponse = myWebRequest.GetResponse();
                StreamReader sr = new StreamReader(myWebResponse.GetResponseStream());
                string res = sr.ReadToEnd();
                sr.Close();