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

C# 刚写的 HttpRequsetResponse 类,异步、事件... 还热乎着呢!

//调用示例:
private void button1_Click(object sender, System.EventArgs e)
{
    HttpRequestResponse xx = new HttpRequestResponse();
    xx.DataArrival += new DataArrivalEventHandler(xx_DataArrival);
    xx.SendRequest("http://www.triaton.com.cn/dotnet/tree/index.asp","userid=老","Post");
    xx.SendRequest("http://www.triaton.com.cn/dotnet/tree/index.asp","userid=老","get");
}
private void xx_DataArrival(object sender, DataArrivalEventArgs e)
{
    Console.WriteLine(e.RecievedData);
    Console.WriteLine(e.IsComplete);
}
//========================
//Class1.cs
using System;
using System.Net;
using System.Threading;
using System.Text;
using System.IO;
public class RequestState
{
    const int BUFFER_SIZE = 1024;
    public System.Text.StringBuilder RequestData;
    public byte[] BufferRead;
    public System.Net.HttpWebRequest Request;
    public System.IO.Stream ResponseStream;
    public System.Text.Decoder StreamDecode = System.Text.Encoding.GetEncoding("gb2312").GetDecoder();
    
    public RequestState()
    {
        BufferRead = new byte[BUFFER_SIZE];
补充:asp.net教程,远程及网络应用
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,