.NET Framework 4 Client Profile + System.Web.dll?

前端 未结 4 1358
被撕碎了的回忆
被撕碎了的回忆 2020-12-11 16:49

I\'m currently developing an application for .NET 4 Client Profile, as this is the version that will be present on most home computers through Windows Update.

Howeve

4条回答
  •  旧巷少年郎
    2020-12-11 17:03

    If you are just wanting to use the HttpWebRequest, it is available in the client profile for .Net 4.

    Here's an example that you can try, just create a new console app using the .Net 4 Client Profile and paste this into Program.cs...

    using System;
    using System.IO;
    using System.Net;
    
    namespace ConsoleApplication3
    {
        class Program
        {
            static void Main(string[] args)
            {
                var request = WebRequest.Create("http://google.com");
                var response = request.GetResponse();
                using (var s = response.GetResponseStream())
                using( var sr = new StreamReader(s))
                {
                    Console.Write(sr.ReadToEnd());
                }
    
                Console.ReadKey();
            }
        }
    }
    

    You asked about HttpCookieCollection in one of your comments. It seems that HttpWebRequest uses a CookieContainer to store the cookies.

提交回复
热议问题