473,467 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

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
2 5631
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Lakshmi Narayanan.R | last post by:
Hi Experts, Using keyword "To" in select case giving error.The following code is got from www.microsrosoft.com itself. What is the wrong with this?. <% Dim Number1 Number1 = 7 ' Initialize...
0
by: BGS | last post by:
I have a web site (www.on-the-matrix.com) that displays photos in a "slide show" format on ASPX pages that run in an inline frame on an ASP page (or in a separate pop-up window). The ASPX pages...
2
by: Maris Janis Vasilevskis | last post by:
Hi, Is it possible to force HttpWebRequest to do exactly (not approximately) the same as MSXML2.ServerXMLHTTP does? More details. I port JScript to JScript.NET I have a server (ASP invoking...
4
by: Rachel McConnell | last post by:
Hello, I have a Java web application using Hibernate to connect to a PostgreSQL backend. I am seeing the below stack trace during processing of a set of data consisting of around 1000 objects;...
23
by: deathtospam | last post by:
A day or two ago, I wrote a quick ASPX page with a CS codebehind using Visual Studio .NET 2005 -- it worked, I saved it and closed the project. Today, I came back to the project, reopened the...
2
by: bepnewt | last post by:
Hello! I'm trying to connect to different sites using an HttpWebRequest object and some of them return an Error 400. If you navigate to it in a normal browser, it works fine. This is an example...
13
by: Kevin Liebowicz | last post by:
Yes, I wasted the past two days trying to fix this. Yes, this is on a Win2003 Server. Yes, this machine is a domain controller. Yes, I seen the dozens of KB articles like this one:...
1
by: Rahul Bhate | last post by:
Hello Sir My problem is in dos giving error that javac is not recognised.Tell me the steps for debugging.I have already set the CLASSPTH through command line & also set the PATH.But still giving...
4
by: mukeshrasm | last post by:
<?php // create new document pdf_new(); $pdf = pdf_new(); pdf_open_file($pdf); pdf_begin_page($pdf, 500, 700); // define a font $font = pdf_findfont($pdf, "Courier", "host", 0);
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.