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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTTP-POST with Cookies

Status
Not open for further replies.

abs2003

MIS
Aug 31, 2004
80
US
I use HttpWebRequest and HttpWebResponse. My problem is that I get "The browser you are using is rejecting cookies". Thought I used CookieContainer to accept cookies. Can anyone help?

Thanks
 
Could you show some code, speciically where you declare the HttpWebRequest, CookieContainer and HttpWebResponse objects?

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
jebenson,
Thank you. Here's my code...

Code:
Dim objLoginRequest As HttpWebRequest = WebRequest.Create(strURL)
            objLoginRequest.CookieContainer = New CookieContainer  
objLoginRequest.Method = "POST"
            objLoginRequest.KeepAlive = True
            strPost = "MfcISAPICommand=SignInWelcome&userid=test&password=test"
 objLoginRequest.ContentLength = strPost.Length
            objLoginRequest.ContentType = "application/x-[URL unfurl="true"]www-form-urlencoded"[/URL]

            Try
                myWriter = New StreamWriter(objLoginRequest.GetRequestStream())
                myWriter.Write(strPost)
            Catch e As Exception
                Return e.Message
            Finally
                myWriter.Close()
            End Try

            Dim objloginResponse As HttpWebResponse = objLoginRequest.GetResponse()
            sr = New StreamReader(objloginResponse.GetResponseStream())

            strHTML = sr.ReadToEnd()
            sr.Close()
 
I got it resolved.
All I have to do is
Use HTTP-GET
Store cookies
Get whatever parameter (hidden value) you need
Use HTTP-POST

If anyone need more detail or sample code posted, please let me know.

Thank you everyone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top