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

E

edsuslen

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.
 
B

Bruce Barker

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)
 
E

ed suslen

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top