Hello,
I am very new C#.
I am trying to log into http://mls.momls.com/SERetsMonmouth/Login.aspx with the following code and I am getting a 401 error. My user name and password are correct. I can manually log in through the browser.
But I am not sure about the code I wrote. It is based on what I read on the internet and after examining someone's code.
Please advice me on what I am doing wrong.
this.digestAuth = this.GetAuth();
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(this.loginUrl);
request.Accept = "*/*";
request.UserAgent = this.userAgent;
request.Headers.Add("RETS-Version", this.version);
request.ProtocolVersion = HttpVersion.Version11;
request.Headers.Add("Authorization", this.digestAuth);
CredentialCache cache = new CredentialCache();
cache.Add(new Uri(this.loginUrl), "Digest", new NetworkCredential(this.userName, this.password));
request.Credentials = cache;
HttpWebResponse response = (HttpWebResponse) request.GetResponse();