Trigger Batch Compile : WebClient « Development « ASP.NET Tutorial






using System;
using System.Net;
using System.IO;
using System.Text;

class TriggerBatchCompile {

private static string[] urls = {
"http://localhost/page.aspx",
"http://localhost/anotherApplication/page.aspx",
"http://localhost/yetAnotherApplication/page.aspx"
};

    public static void Main(string[] args) {
        WebResponse result = null;
        for(int i = 0; i < urls.Length; i++) {
            try {
                Console.WriteLine(urls[i]);
                WebRequest request = WebRequest.Create(urls[i]);
                result = request.GetResponse();
                Stream receiveStream = result.GetResponseStream();
                StreamReader streamReader = new StreamReader(receiveStream);
                char[] read = new Char[256];
                int count = streamReader.Read( read, 0, 256 );
                while (count > 0) {
                    count = streamReader.Read(read, 0, 256);
                }
            }
            catch(Exception e) {
                Console.WriteLine(e);
            } 
            finally {
                if ( result != null ) {
                    result.Close();
                }
            }
        }
    }
}








9.46.WebClient
9.46.1.Trigger Batch Compile
9.46.2.Read page header
9.46.3.asynchronous page downloading
9.46.4.Retrieve web page