Using VB.NET to login to a Domino site

Here is a short example of logging in to a Domino server using Visual Basic .NET.

Dim postData As String postData = "username=MyUserName&password=mysecretpassword1234" Dim request As HttpWebRequest Dim response As HttpWebResponse request = CType(WebRequest.Create("http://server.com/names.nsf?Login"), HttpWebRequest) request.ContentType = "application/x-www-form-urlencoded" request.ContentLength = postData.Length request.Method = "POST" request.AllowAutoRedirect = False Dim requestStream As Stream = request.GetRequestStream() Dim postBytes As Byte() = Encoding.ASCII.GetBytes(postData) requestStream.Write(postBytes, 0, postBytes.Length) requestStream.Close() response = CType(request.GetResponse(), HttpWebResponse) Console.WriteLine(New StreamReader(response.GetResponseStream()).ReadToEnd()) Console.WriteLine("Headers:") Console.WriteLine(response.Headers.ToString())