Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The remote server returned an error: (403) Forbidden

Status
Not open for further replies.

dpdoug

Programmer
Nov 27, 2002
455
US
I'm trying to login to a certain site using the HttpWebRequest, but right from the beginning of my code (in testing) I'm getting the following error:

Code:
The remote server returned an error: (403) Forbidden. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Net.WebException: The remote server returned an error: (403) Forbidden.

Source Error: 


Line 38: 
Line 39: Dim webRequest As HttpWebRequest = webRequest.Create(LOGIN_URL)
[COLOR=red]Line 40: Dim responseReader As StreamReader = New StreamReader(webRequest.GetResponse.GetResponseStream)[/color]
Line 41: Dim responseData As String = responseReader.ReadToEnd
Line 42: responseReader.Close()

Is there anyone that is familiar with this technique that can help me with this?

 
That code worked for me when I set the LOGIN_URL to a page on this site.

Either you don't have access to the page you are requesting or there is a problem with the page (that's my guess anyway).

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
The LOGIN_URL is a secure site (https), so I am guessing that the error has something to do with the X509Certificate.

One of the examples that I am going by uses these lines:

Code:
Dim req As HttpWebRequest = WebRequest.Create(uri)
...
Dim cert As IntPtr = CType(xmlsettings.read("parent", "childsetting"), IntPtr)
  Dim certX509 As New X509Certificate(cert)
  req.ClientCertificates.Add(certX509)
(
I'm supposing that the author is pulling the name of the certificate stored in the web.config file. If this is the case, is there any way that I could get the name of this certificate?
 
I figured out the problem: I was using http instead of https.

When I changed that it solved my problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top