473,772 Members | 3,672 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

vb2008 HttpWebRequest "post"

1 New Member
Hi all, I have problem on use HttpWebRequest with "POST" method.
First, I access
http://store.apple.com/hk-zh/configu...=UNLO CKED%2FWW
this link and go to the cart page.
Then when I change the quantity to 2, I had see the live http header to use "POST" and submit the content to the server.
I follow the header and write with vb2008, but I get the server return 503 error on the code that getting response, would you mind to tell me that I got problem on where?

Expand|Select|Wrap|Line Numbers
  1. logincookie = New CookieContainer()
  2.      Try
  3.      'access item page
  4.      req = DirectCast(WebRequest.Create("http://store.apple.com/hk-zh/configure/MD198ZP/A?option.iphone_applecare=none&option.iphone_bumpers=none&option.iphone_4_dock=none&option.additional_apple_usb_power_adaptor=none&option.additional_apple_dock_connector_to_usb_cable=none&add-to-cart=add-to-cart&cppart=UNLOCKED%2FWW"), HttpWebRequest)
  5.      req.Method = "GET"
  6.      req.UserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1"
  7.      req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
  8.      req.Headers("Accept-Language") = "zh-tw,en-us;q=0.7,en;q=0.3"
  9.      'req.Headers("Accept-Encoding") = "gzip, deflate"
  10.      req.Headers("Accept-Charset") = "UTF-8,*"
  11.      req.KeepAlive = True
  12.      req.CookieContainer = logincookie
  13.  
  14. response = DirectCast(req.GetResponse(), HttpWebResponse)
  15.      For Each tempCookies In response.Cookies
  16.      logincookie.Add(tempCookies)
  17.      Next
  18.  
  19.      reqreader = New StreamReader(response.GetResponseStream())
  20.      htmltext = reqreader.ReadToEnd
  21.      reqreader.Close()
  22.      response.Close()
than post data(i sure that the post content are correct)

Expand|Select|Wrap|Line Numbers
  1.  byteData = encoding.GetBytes(postdata)
  2.      req.ContentLength = byteData.Length
  3.      postreqstream = req.GetRequestStream()
  4.      postreqstream.Write(byteData, 0, byteData.Length)
  5.      postreqstream.Close()
  6.  
  7. 'server return 503 in this code
  8.      response = DirectCast(req.GetResponse(), HttpWebResponse)
  9.  
  10.      reqreader = New StreamReader(response.GetResponseStream())
  11.      htmltext = reqreader.ReadToEnd
  12.      reqreader.Close()
  13.      response.Close()
i have error on "response = DirectCast(req. GetResponse(), HttpWebResponse )"

For programmers: provide error codes, snippets of code related to error code(no longer than 20 lines)
sorry i may be more than 20 lines a little bit...
Feb 20 '12 #1
0 1373

Sign in to post your reply or Sign up for a free account.

Similar topics

16
12647
by: thomas peter | last post by:
I am building a precache engine... one that request over 100 pages on an remote server to cache them remotely... can i use the HttpWebRequest and WebResponse classes for this? or must i use the MSHTML objects to really load the HTML and request all of the images on site? string lcUrl = http://www.cnn.com; // *** Establish the request
6
4213
by: Mike Koerner | last post by:
Hi, I am having problems setting the HttpWebRequest Date header. I understand that it is a restricted header and I do receive the "This header must be modified with the appropriate property." Is there a way to make sure that the date header is sent over or a way to work around this exception? Here's a sample of the code:
7
2541
by: Arthur Dent | last post by:
Does anyone know where i can find a decently thorough list of the language changes in VB2008, such as the new If() function? All i can seem to find through search engines, most of the articles all talk about LINQ, with only cursory mention - at best - of any other new features. Thanks in advance, ... Arthur Dent.
2
3443
by: Arthur Dent | last post by:
I am trying to make a VB2008 Express winforms project, and edit the form. However, when i try to open the form, i get this error: ..NET Framework 2.0 update not found. The win32manifest will not be embedded. It considers it a fatal error, and will not let me edit the form, either in code or design view. I have frameworks 1.1, 2.0, 3.5 installed, and all Windows Updates (sans DreamScene).
6
2680
by: Academia | last post by:
I have a computer at home with a (slow) dialup connection and a computer at school with a fast connection. I want to go there (it is not close) and down load Vb2008 express, burn it into a CD, bring it home and install it on my home computer. Someone told me it can't be done. Is there a way of doing that?
8
3216
by: Galen Somerville | last post by:
My graphics involves a lot of line drawings in a short period of time. I have all the graphics in a separate module. I repeatedly get the pixel data from a USB device, draw the requisite traces, get more data, draw traces, etc. The USB appears to take 82 ms between bursts of data. But the drawing is taking 178 ms !!! It's a real time display, like an oscilloscope, whereby I have to blank the
6
4499
by: Scott Gravenhorst | last post by:
Windows XP SP3 My application is set to open a SaveFile dialog when an exit is requested. When I click the app's close button, the save dialog opens, but when I click to change the folder, the exception occurs pointing to FileSaveDialog1.ShowDialog(). The exception also indicates some problem with system.drawing.dll. The exception text is: "Attempted to read or write protected memory. This is often an
9
1195
by: MichaelH | last post by:
Are there any definite advantages of VB2008 over VB2005? Thank in advance. Michael
0
1241
by: John Dann | last post by:
Looking to migrate from VB2005 Pro to VB2008. Can anyone suggest/recommend a VB2008 book that highlights the changes from earlier versions of VB.Net (VB2003/2005) rather than describing VB2008 totally from scratch? I suspect that this may be asking too much in that few books will focus exclusively on migrating/upgrading, but there still may be something out there that is written with existing users of VB.Net in mind. I'm obviously looking...
3
2048
by: patricia3d | last post by:
I was trying to upgrade my project from VB6 to VB2008 Upgrade Error Line For Each oText In Me.txtFields oText.DataSource = adoPrimaryRS Next oText
0
9620
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10104
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8934
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6715
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.