Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
| Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 18th, 2004, 02:52 AM
Registered User
Join Date: Dec 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default cannot retrieve data because of redirecting

hi guys,
i have a problem with retrieving data from nytimes.com website. find below the code that i have written. nytimes.com requires login to see the content. i send the login information in postData, however i am not redirected to the proper address, but to the login page. however when i try the url with the postdata it actually works in browsers. is there someone overthere to help.

PS: you need a userid and pass to actually run this script

 Public Function RetrievePage()
        Dim postData As String
        postData = "URI=http://www.nytimes.com/2004/12/09/garden/09TURF.html&USERID=heregoesyourid&PASSWORD=heregoe syourpass&is_continue=true&SAVEOPTION=Yes"
        Dim request As HttpWebRequest
        Dim response As HttpWebResponse
        request = CType(WebRequest.Create("http://www.nytimes.com/auth/login"), HttpWebRequest)
        request.ContentType = "text/html;iso-8859-1"
        request.ContentLength = postData.Length
        request.Method = "POST"
        request.AllowAutoRedirect = True

        Dim requestStream As Stream = request.GetRequestStream()
        Dim postBytes As Byte() = Encoding.ASCII.GetBytes(postData)
        requestStream.Write(postBytes, 0, postBytes.Length)
        response = CType(request.GetResponse(), HttpWebResponse)
        Dim r As New StreamReader(response.GetResponseStream())
        Dim Page As String = r.ReadToEnd()

    End Function

Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieve different data from same table /field W052107 Visual Studio 2005 7 August 6th, 2007 10:40 AM
retrieve data dynamically pitiporn Classic ASP Basics 3 May 28th, 2006 11:21 PM
Retrieve data Snib C++ Programming 2 November 6th, 2004 11:09 AM
trying to retrieve data from another page Calibus Classic ASP Databases 3 July 17th, 2004 11:51 PM
data retrieve from three tables mateenmohd SQL Server 2000 2 October 7th, 2003 04:26 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.