.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 5th, 2003, 07:06 PM
JayPak JayPak is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 1 JayPak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
HttpWebRequest and Querystring

I am using the httpwebrequest class to scape data from a webpage. If I do not include any name/vale pairs in the link, I get the default data, which is today's data with today's date. Now, if I want to get data from another day, I need to pass 'marketdate=2003-03-03' (in this case I would get Mar 3rd data) as the querystring. When I pass this as the link (include the querystring in the link) OR if I get a stream writer to 'write' it, it is ignored. If I enter the link into my web browser (IE6), it ignores the querystring as well, until I refresh. Once I do this, the proper date pulls up. <br><br>The name 'marketdate' is correct - I have made sure of that. My question is, how do either get my httpwebrequest object to successfully pass thge querystring, or how do I mimick the behavior of IE6 (as mentioned above)? My thought was to some how open a connection (thru the socket class?) and keep that connection open while I pass the querystring to it. <br><br>Anyone got any ideas or run into anythign similar? <br><br>Here is my code as it stands now: <br><br>'create web request to get the webpage with data <br>Dim sLink As String <br><br>sLink = "http://somesite.com/jsp/somedata.jsp" <br>Dim sQuery As New System.Text.StringBuilder() <br><br>sQuery.Append("marketdate=2003-03-03") <br><br>Dim req As HttpWebRequest = WebRequest.Create(sLink) <br><br>'must use x509 certificate to connect <br>'req.ClientCertificates.Add(X509Certificate.Create FromCertFile("C:X509.cer")) <br>req.ContentType = "application/x-www-form-urlencoded" <br>req.Method = "POST" <br>req.ContentLength = sQuery.Length <br><br>Dim w As StreamWriter = New StreamWriter(req.GetRequestStream) <br>w.Write(sQuery.ToString) <br>w.Close() <br><br>Dim r As HttpWebResponse = req.GetResponse <br><br>'get webpage with data <br>Dim reader As New StreamReader(r.GetResponseStream) <br><br>'dump the webpage into a string variable <br>Dim x As String = reader.ReadToEnd <br><br>'write out to file for parsing <br>Dim writer As New StreamWriter("C:stuff.txt") <br>writer.Write(x) <br>writer.Flush() <br>writer.Close() <br><br>Any help would be appreciated! <br><br>Thanks!

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > HttpWebRequest and Querystring


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT