//Console.Write("\nPlease enter the URL to post data to : ");
            string uriString = "http://localhost:62711/Default.aspx";

            // Create a new WebClient instance.
            WebClient myWebClient = new WebClient();

            // Create a new NameValueCollection instance to hold some custom parameters to be posted to the URL.
            NameValueCollection myNameValueCollection = new NameValueCollection();

            Console.WriteLine("Please enter the following parameters to be posted to the URI");
            Console.Write("Name:");
            string name = Console.ReadLine();

            Console.Write("Age:");
            string age = Console.ReadLine();

            Console.Write("Address:");
            string address = Console.ReadLine();

            // Add necessary parameter/value pairs to the name/value container.
            myNameValueCollection.Add("Name", name);
            myNameValueCollection.Add("Address", address);
            myNameValueCollection.Add("Age", age);
            Console.WriteLine("\nUploading to {0} ...", uriString);

            // Upload the NameValueCollection.
            byte[] responseArray = myWebClient.UploadValues(uriString, "POST", myNameValueCollection);

            // Decode and display the response.
            Console.WriteLine("\nResponse received was :\n{0}", Encoding.ASCII.GetString(responseArray));

arrow
arrow
    文章標籤
    C#
    全站熱搜
    創作者介紹
    創作者 芭樂養樂多 的頭像
    芭樂養樂多

    隨手筆記

    芭樂養樂多 發表在 痞客邦 留言(0) 人氣()