Remote website login via ASP code

Posted on 2009-02-20
Last Modified: 2012-05-06
I have inherited an old ASP 2.0 application that remotely logs in to a paid subscription website and then retrieves data for processing, basically impersonating actions that would otherwise be done with a browser.  The target website has recently upgraded their site and is using ASP.NET.   The "name" tags for the login form (and other form fields) are all changed and appear to be dynamically generated.  I don't know ASP.NET but it appears that these form fields were created using some sort of ASP.NET handler.  My login routine no longer works as it seems the "name" attributes that I'm passing in aren't being recognized.  Here's the section of the target sites login form:
<input name="ctl00$ContentPlaceHolder1$SectionLogin1$Username" type="text" id="ctl00_ContentPlaceHolder1_SectionLogin1_Username" />
<p class="text-Smaller-Bold" align="center">
    Password:<br />
    <input name="ctl00$ContentPlaceHolder1$SectionLogin1$Password"
I've tried passing the following and neither has worked:

      oHttp.Open "POST","",False
      oHttp.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"

      oHttp.Send "Username=MYUSERNAME&Password=MYPASSWORD"

oHttp.Send "ctl00$ContentPlaceHolder1$SectionLogin1$Username=MYUSERNAME&ctl00$ContentPlaceHolder1$SectionLogin1$Password=MYPASSWORD"

Any assistance would be greatly appreciated.


Question by:emilysam
    LVL 15

    Accepted Solution

    If they are using, one of the security features of is to prevent post backs to a form from a remote source.

    The ID ctl00$ContentPlaceHolder1$SectionLogin1$Username specifies the location of the Username textbox.

    ctl00 = aspnetForm
    ContentPlaceHolder1 = Content section of MasterPage
    SectionLogin1 = Custom User Control
    Username = ID of the TextBox

    The way would handle that is __doPostBack('ctl00$ContentPlaceHolder1$SectionLogin1$Username',''), which would POST several things, including an __EVENTTARGET and __VIEWSTATE.  

    I don't think you will be able to do what you are wanting to do, unless that website explicetly has something on their login page to allow remote logins.

    Author Comment

    that's what I was afraid of and it makes sense as these sites typically don't want automated searches unless it's through an interface they provide.  Thanks for the input.  I'll hold the question open for a couple of days to see if there are other ideas.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    This video discusses moving either the default database or any database to a new volume.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now