public String GetWebContent(String username, String password) { String _retVal = "err001"; String _urlLogin = ""; String _urlSignin = ""; String _respStr = ""; String _postData = ""; Uri _uriLogin = null; Uri _uriSignin = null; _urlLogin = "http://rm.test.nl/projects/tetrahis/issues"; // is the login Page _urlSignin = "http://rm.test.nl/login?back_url=http%3A%2F%2Frm.test.nl%2Fprojects%2Ftetrahis%2Fissues"; //is the link used inside the action of the form tag (Note: I suppose in this example that the form name inside the _urlLogin page is "loginForm") _uriLogin = new Uri(_urlLogin); _uriSignin = new Uri(_urlSignin); try { HttpWebRequest _wReq; HttpWebResponse _wResp; System.IO.StreamReader _sr; System.Text.ASCIIEncoding _enc = new System.Text.ASCIIEncoding(); CookieContainer _cookies; _wReq = (HttpWebRequest) WebRequest.Create(_uriLogin); _wReq.CookieContainer = new CookieContainer(); _wReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; _wResp = (HttpWebResponse) _wReq.GetResponse(); _sr = new System.IO.StreamReader(_wResp.GetResponseStream()); _respStr = _sr.ReadToEnd(); _sr.Close(); _cookies=_wReq.CookieContainer; _wResp.Close(); Hashtable _otherData; // in an initialization routine _otherData = new Hashtable(); _otherData.Add("username", new Hashtable()); _otherData.Add("password", new Hashtable()); //Here insert all the parameter needed for the login... eg: in my example I suppose that the loginForm has two input field named "username" and "password" ((Hashtable)_otherData["username"])["value"] = username; ((Hashtable)_otherData["password"])["value"] = password; //you could need to insert other information _postData = ""; foreach(string name in _otherData.Keys) { _postData += "&" + name + "=" + ((Hashtable)_otherData[name])["value"]; } _postData = _postData.Substring(1); byte[] _data = _enc.GetBytes(_postData); _wReq = (HttpWebRequest) WebRequest.Create(_uriSignin); _wReq.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; _wReq.Referer = _urlLogin; _wReq.KeepAlive = true; _wReq.Method = "POST"; _wReq.ContentType = "application/x-www-form-urlencoded"; _wReq.ContentLength = _data.Length; _wReq.CookieContainer = _cookies; _wReq.AllowAutoRedirect = false; _wReq.UserAgent = "Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; System.IO.Stream _outStream = _wReq.GetRequestStream(); _outStream.Write(_data,0,_data.Length); _outStream.Close(); _wResp = (HttpWebResponse) _wReq.GetResponse(); _sr = new System.IO.StreamReader(_wResp.GetResponseStream()); _respStr = _sr.ReadToEnd(); _sr.Close(); _wResp.Close(); // _respStr contains the page content... use this for your needed. _retVal=_respStr; } catch(Exception ex) { string err = ex.ToString(); throw ex; //Response.Write(e.ToString()); return null; } return _retVal; }