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

Discussion in 'ASP .Net' started by edsuslen@yahoo.com, Sep 26, 2005.

  1. Guest

    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.
     
    , Sep 26, 2005
    #1
    1. Advertising

  2. Bruce Barker Guest

    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)

    <> wrote in message
    news:...
    >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.
    >
     
    Bruce Barker, Sep 26, 2005
    #2
    1. Advertising

  3. ed suslen Guest

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

    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
     
    ed suslen, Sep 27, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chun
    Replies:
    2
    Views:
    563
  2. JN
    Replies:
    0
    Views:
    145
  3. Replies:
    4
    Views:
    724
    Dominick Baier
    Nov 23, 2006
  4. Water

    Remote Server returned an error (403)

    Water, Jun 27, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    118
    Water
    Jun 27, 2004
  5. willem joubert

    Error 403-Error 403-Error 403

    willem joubert, Feb 8, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    180
    Bruce Johnson [C# MVP]
    Feb 8, 2005
Loading...

Share This Page