Results 1 to 4 of 4

Thread: [2005] HttpWebRequest not sending cookies

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2003
    Location
    Melbourne, Australia
    Posts
    13

    [2005] HttpWebRequest not sending cookies

    So, i figure after a week of exhausting every possible stupid reason for this, somehow when i send a HttpWebRequest with cookies attached the site either doesnt get the cookies or doesnt accept them.. the server is Apache Tomcat 6.0 if that matters.. and also i set up a test using an old ASP page i had, and i know it works on other pages, yet on this server it doesnt hold or use the cookies..

    heres my code too:
    Code:
    Private CookieCont As New CookieContainer
    
    Private Function GetWebData(ByVal strURL As String) As String
      objWebRequest = HttpWebRequest.Create(strURL)
      With objWebRequest
        .CookieContainer() = CookieCont
        .UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"
        .Timeout = 4000
        Dim strOutput As String = New StreamReader(.GetResponse().GetResponseStream()).ReadToEnd
      End With
      GetWebData = strOutput
    End Function
    
    
    Private Function PostWebData(ByVal strURL As String, ByVal strPostData As String) As String
      objWebRequest = HttpWebRequest.Create(strURL)
      Dim ToSend As Byte() = System.Text.Encoding.ASCII.GetBytes(strPostData)
      With objWebRequest
        .Method = "POST"
        .UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"
        .ContentType = "application/x-www-form-urlencoded"
        .CookieContainer() = CookieCont
        .Timeout = 4000
        Dim objSendtoServer As Stream = .GetRequestStream
        objSendtoServer.Write(ToSend, 0, ToSend.Length)
        objSendtoServer.Close()
        Dim strOutput As String = New StreamReader(.GetResponse().GetResponseStream()).ReadToEnd
      End With
      PostWebData = strOutput
    End Function
    so basicly, when i log in using the PostWebData function, and then use the GetWebData function to get the next page, no cookies go with it and the server think's i've logged out.. i've put in code to count and look at the cookies and it seams, even if i manually add them they still dont exist for some reason..

    i thought it may have also been the URL, because the site is on a different port alike: http://example.blah.com:8080/login (and no i cant just use: http://example.blah.com/login) cause the port is the only way in

    So does anyone have any idea, cause i am truely stumped

  2. #2

    Thread Starter
    New Member
    Join Date
    Nov 2003
    Location
    Melbourne, Australia
    Posts
    13

    Re: [2005] HttpWebRequest not sending cookies

    *bump*

    anyone got anything?

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2003
    Location
    Melbourne, Australia
    Posts
    13

    Re: [2005] HttpWebRequest not sending cookies

    *More bump*

    no one has nothing at all?

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2003
    Location
    Melbourne, Australia
    Posts
    13

    Re: [2005] HttpWebRequest not sending cookies

    *sighs*

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width