By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,466 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,466 IT Pros & Developers. It's quick & easy.

HttpWebRequest is giving: "Error on HTTP request: The remote server returned an error: (403) Forbidden."

P: n/a
I am migrating working code (HTTPRequest with Authentication) from vb
to vb.net

vb:
Set objXMLHTTPServer = New MSXML2.XMLHTTP30
objXMLHTTPServer.Open strMethod, strGetRequest, False, "UserId",
"Password"
objXMLHTTPServer.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
....
objXMLHTTPServer.send (varPostData)

is getting data from our clients without a problem, similar code in
..net:

Dim req As HttpWebRequest
req = CType(WebRequest.Create(strURL), HttpWebRequest)
req.Credentials = New System.Net.NetworkCredential("UserId",
"Password")
req.ContentType = "application/x-www-form-urlencoded"
....
dim funSendHTTPRequest as WebResponse = req.GetResponse()

giving "Error on HTTP request: The remote server returned an error:
(403) Forbidden."

What am i missing?
Any help is appreciated.

Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
failed authenication is a 401, 403 is a forbidden url (usually a browse
directory request). check that the url is correct, also what did you set the
Method to?

-- bruce (sqlwork.com)

<ed******@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I am migrating working code (HTTPRequest with Authentication) from vb
to vb.net

vb:
Set objXMLHTTPServer = New MSXML2.XMLHTTP30
objXMLHTTPServer.Open strMethod, strGetRequest, False, "UserId",
"Password"
objXMLHTTPServer.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
...
objXMLHTTPServer.send (varPostData)

is getting data from our clients without a problem, similar code in
.net:

Dim req As HttpWebRequest
req = CType(WebRequest.Create(strURL), HttpWebRequest)
req.Credentials = New System.Net.NetworkCredential("UserId",
"Password")
req.ContentType = "application/x-www-form-urlencoded"
...
dim funSendHTTPRequest as WebResponse = req.GetResponse()

giving "Error on HTTP request: The remote server returned an error:
(403) Forbidden."

What am i missing?
Any help is appreciated.

Nov 19 '05 #2

P: n/a
Method is post.
I did not put all the code thatís irrelevant,
Code works with get a post; Iíve tested it with few other sides that do
not require
authentication.
URL is correct; I am using the same one that is working from vb 6
without a problem for a few years now.
The problem is in .net authentication, am I using proper statement
req.Credentials = New System.Net.NetworkCredential("IAA", "IAA")
and is their anything else I should do?

Thanks in advance.
--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.