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

asp.net 怎么发送http post的请求

asp.net 怎么发送http post的请求 post http  --------------------编程问答--------------------

<form action="checkUser.html" method="POST">
</form>
--------------------编程问答-------------------- 用jquery的Post???? --------------------编程问答-------------------- 默认就是Post的吧 --------------------编程问答-------------------- 是C#后台怎么发, HttpListener listener = new HttpListener();
            listener.Prefixes.Add("http://192.10.1.120:10000/"); //要监听的url范围
            listener.Start();   //开始监听端口,接收客户端请求
            Console.WriteLine("Listening");

            try
            {
                while (true)
                {
                    //获取一个客户端请求为止
                    HttpListenerContext context = listener.GetContext();
                    //将其处理过程放入线程池
                    System.Threading.ThreadPool.QueueUserWorkItem(ProcessHttpClient, context);
                }
            }
            catch (Exception e)
            {

                Console.WriteLine(e.Message);
            }
            finally
            {
                listener.Stop();    //关闭HttpListener
            }

已经监听客户端了,然后得到客户端的消息,处理之后怎么以发一条响应的http报文给客户端 --------------------编程问答-------------------- HttpWebRequest
http://www.cnblogs.com/tuyile006/archive/2008/11/14/1333632.html --------------------编程问答-------------------- #region 发送 http/post 请求到
    /// <summary>
    /// 发送 http/post 请求到
    /// </summary>
    /// <param name="url"></param>
    /// <param name="prams">参数集合</param>
    /// <returns>返回服务端相应的字符串</returns>
    public static string SendHttpPost(this string url, NameValueCollection data)
    {
        System.Net.WebClient wc = new System.Net.WebClient();
        wc.Headers.Add("Accept-Language", "zh-cn");
        wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
        byte[] bytReturn = wc.UploadValues(url, "post", data);
        wc.Dispose();
        return System.Text.Encoding.GetEncoding("gbk").GetString(bytReturn);
    }
    #endregion --------------------编程问答-------------------- 谢谢 浮云也疯狂 和Andrewsway
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,