Results 1 to 6 of 6

Thread: WebClient Login

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    UK
    Posts
    489

    WebClient Login

    Hey

    Well I'm trying to log into Squidoo and simply download data from basically your own dashboard, I've written this in C sharp but I don't think it matters tbh.

    vb Code:
    1. Private Sub LoginSquidoo()
    2.         Dim wc As New WebClient()
    3.        
    4.        Dim nc As New NetworkCredential("email", "password", "http://www.squidoo.com/member/login")
    5.        
    6.         wc.Credentials = nc
    7.         Try
    8.             Dim response As Byte() = wc.DownloadData("http://www.squidoo.com/lensmaster/dashboard")
    9.             Dim result As String = Encoding.ASCII.GetString(response)
    10.            richTextBox1.Text = result
    11.        Catch e As Exception
    12.           MessageBox.Show("Exception", e.ToString())
    13.        End Try
    14.      End Sub

    I'm getting no errors, and analysing the HTML within the result string just shows the login page, without an error or anything, it's like I just browse to the login page and did nothing. The login page looks simple enough, maybe a POST or something, but maybe the authentication scheme just doesn't work with this, advice appreciated.
    Learning C♯

    Data Binding & Bound Controls - Objects and wizards will never be as intelligent as you, do it yourself! (Unless your Pro)

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: WebClient Login

    The third argument is a domain, not a web page URL. I'm not 100% sure that will fix the issue but it's a start.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    UK
    Posts
    489

    Re: WebClient Login

    Thanks for the tip, I tried it with the domain, but sadly nothing changed, here's the code of the login text boxes and submit button

    Code:
    		<form method="post" action="http://www.squidoo.com/member/login" id="loginForm"
    				onsubmit="return validate(this);">
    		  			<fieldset>
    				<div class="row">
    					<label for="email">Your Email</label>
    					<input required="true" validate="email" type="text" value="" tabindex="1"
    							name="email_address" id="email_address"  />
    				</div>
    
    				<br />
    
    				<div class="row">
    					<label for="password">Password</label>
    					<input required="true" type="password" value="" tabindex="2"
    							name="member_password" id="member_password" />
    				</div>
    
    				<br />
    
    	      <div class="row">
    					<input type="checkbox" name="remember_me" id="remember_me" value="1" tabindex="3"
    							 style="width:2em;float:left;" />
    
    					<label for="remember_me">Remember me</label>
    	      </div>
    			</fieldset>
    
    			<div class="break"></div>
    			<div class="rowSubmit">
    				<input name="loginButton" type="image" src="http://cdn.squidoo.com/images/btn-login.gif"
    						alt="Log in" class="button" tabindex="5" />
    			</div>
    		</form>
    Learning C♯

    Data Binding & Bound Controls - Objects and wizards will never be as intelligent as you, do it yourself! (Unless your Pro)

  4. #4

    Re: WebClient Login

    I've written this in C sharp but I don't think it matters tbh.
    I'm more focused on this line. If you read the Forum Hierarchy level from this post, you'll clearly see that it goes:
    VBForums > Visual Basic > Visual Basic .NET
    And yet your code appears to be like Visual Basic .NET even though you say it was written in C Sharp. I'm sorry, but I still don't get that.

    Anyway, I don't see where you are throwing any data at the form. It just looks like you're focusing on the two controls: email, and password, but you aren't throwing it any data.

    But I could be wrong, since your code appears to be converted to Visual Basic .NET, because you said you wrote it in C Sharp.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    UK
    Posts
    489

    Re: WebClient Login

    Hi
    I’m quite sure my reading comprehension is adequate, but thanks for clarifying this is the Visual Basic .Net sub forum, very helpful. Yes I’m writing a project in C #, but I already know VB syntax therefore it only took me a short amount of time to type it in VB, as language isn’t the issue, and I would get a better response from this sub forum.

    Anyway back on topic, I guess I was hoping to invoke some sort of web request and it would just work heh, anyway I think using the HttpWebRequest class looks the better solution, I’ll try it out tomorrow.
    Learning C♯

    Data Binding & Bound Controls - Objects and wizards will never be as intelligent as you, do it yourself! (Unless your Pro)

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: WebClient Login

    Guess what: if you're using a WebClient then you're already using an HttpWebRequest. The WebClient is simply a wrapper for common operation that use WebRequest objects. If you call WebClient.DownloadData on an HTTP URL then it will internally create an HttpWebRequest and call BeginGetResponse.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width