software products and customization
Contact: support@xuebrothers.net ActiveWEBC Home Page

Sample Codes for Using ActiveWEBCC in C#


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ACTIVEWEBCLib;

namespace UseActiveWEBC
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Sample Program Using ActiveWEBC in C#\n");
            Request req=new ACTIVEWEBCLib.Request();
            req.Method="POST";
            req.Host="www.xuebrothers.net";
            req.path="/cgi-bin/upload_test.cgi";
            req.AddFormText("user", "xue");
            req.AddFormText("password", "12345");
            req.AddFormFile("file1", "d:\\temp\\a.txt");
            req.AddFormFile("file2", "d:\\temp\\b.zip");
            Response resp=req.DoRequest();
            if(resp==null)
            {
                Console.WriteLine(req.LastError);
            }
            else
            {
                Console.Write(resp.GetHeader());
                String ct=resp.GetHeaderValue("Content-Type");
                if(ct.IndexOf("text/")!=0 && ct.IndexOf("message/")!=0)
                {
                    Console.WriteLine("The response content is not of text. Dumping skipped.");
                }
                else
                {
                    Console.Write(resp.GetBody());
                }
            }
        }
    }
}
The Screenshot of the Program