TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Peman Malek
NA
1
8.6k
HttpWebRequest with SSL
Oct 21 2010 5:05 AM
Hello I am having a bit of trouble trying to read data off of a https URL.
When I try to access the site with the code below I get a 401 Unauthorized
error code.
I have spoken with the server admin and he investigated and found out that I
am getting a 401.1 error which indicates that the login info I passed via
credentials is invalid.
I am not sure why this is because I am putting the correct login information
and I verify this by accessing the site via the browser and using the same
login info.
Is there a reason that the login info data is not being sent properly to the
server for authentication?
I have tried fixing this for a while and I did a bit of research on it and
cannot find any answers.
If anyone has some info or advice I would greatly appreciate it.
I put my test code below:
try
{
HttpWebRequest webRequest = (HttpWebRequest)
WebRequest.Create(new Uri("
https://mysite.com/test.html
"));
NetworkCredential creds = new NetworkCredential("myuserid", "mypassword",
"mydomain");
webRequest.Credentials = creds;
webRequest.Method = "GET";
// setup request stream
HttpWebResponse webResp = (HttpWebResponse)webRequest.GetResponse(); //
401 unauthorized error exception
Console.WriteLine(webResp.StatusCode);
Console.WriteLine(webResp.Server);
Stream answer = webResp.GetResponseStream();
StreamReader _answer = new StreamReader(answer);
Console.WriteLine(_answer.ReadToEnd());
}
catch (WebException wEx)
{
Console.WriteLine("Debug Message: " + wEx.Message);
}
Reply
Answers (
1
)
upload image using magic ajax
How To Get Control Events in Custom Control Back To Parent Form