// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; using System.Net; namespace E { public class MainClass { public static string GetContent(string url, CookieContainer session) { HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(url); wr.CookieContainer = session; string html = (new StreamReader(wr.GetResponse().GetResponseStream())).ReadToEnd(); return html; } public static void Main(string[] args) { CookieContainer session = new CookieContainer(); string login = GetContent("http://localhost:8080/logintest/login.jsp?username=arne&password=hemmeligt", session); Console.WriteLine(login); string other = GetContent("http://localhost:8080/logintest/other.jsp", session); Console.WriteLine(other); } } }