Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional 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
  #1 (permalink)  
Old February 10th, 2009, 02:57 AM
Authorized User
 
Join Date: Jan 2009
Location: thanjavur,india
Posts: 43
Thanks: 0
Thanked 2 Times in 2 Posts
Default Login to a website

I need to write a windows application to automatically login to a website(with username and password being provided) to retrieve some data from the website. Can someone show me an example on how to accomplish this in VB.NET?
__________________
dinesh s

Last edited by dinesh; February 10th, 2009 at 03:23 AM..
  #2 (permalink)  
Old February 10th, 2009, 11:17 AM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

You can handle authentication from a Windows application exactly as you would handle authentication from a web application.

There is nothing that prevents you from adding a reference to System.Web and using the System.Web.Security namespace in Windows. Then, you could use the Membership.ValidateUser method.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
  #3 (permalink)  
Old February 10th, 2009, 05:16 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

I think he means he wants his windows .exe to "screen scrape" some web site. So I don't think there is any question of authentication, per se, in use here. I think he just needs to "login" to the web site, using the right username and password, and then hit the page he wants to scrape. Naturally, he will likely need to remember any cookies and pass them back to the page he wants to scrape.

Just a guess. Hopefully, he will give us better info on what he is really doing.
  #4 (permalink)  
Old February 10th, 2009, 05:36 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

I'm not getting where you assume he wants to scrape the screen. He said he wants to "retrieve some data", which I suppose could mean a lot of things.

No matter though. I'm not sure I agree with you about this not being a question of authentication. The act of "logging in" to a site means you are asking the site to authenticate your identity, using a supplied name and password. If you use the Membership.ValidateUser(name. password) method and supply valid credentials, you are "logged in", which is to say, you are "authenticated."

I also don't see where cookies would apply here. An authentication cookie is only useful for "staying" logged in as you navigate a site. If he only needs to hit one page, of what use would a cookie be?

Yiou are right though, we are both whistling in the dark without more information...
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
  #5 (permalink)  
Old February 10th, 2009, 05:44 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Ummm...and how would you use ASP.NET Membership.ValidateUser on a PHP site??? <grin style="sneaky"/>

I would bet that 90% of existing sites use session-based credentials and a starting login page, which is why I suggested the need to maintain cookies. But 90% isn't 100%, of course.

Never mind. Let's see what Dinesh comes back with.
  #6 (permalink)  
Old February 10th, 2009, 05:51 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Quote:
Originally Posted by Old Pedant View Post
Ummm...and how would you use ASP.NET Membership.ValidateUser on a PHP site??? <grin style="sneaky"/>
Damn, you got me there. You ARE sneaky!
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
  #7 (permalink)  
Old February 23rd, 2009, 06:18 AM
Authorized User
 
Join Date: Jan 2009
Location: thanjavur,india
Posts: 43
Thanks: 0
Thanked 2 Times in 2 Posts
Default from dinesh

hi frnds, sorry for very late reply.

I just want to access the page which is restricted by using session. in simple , i just want to access the page by setting the session value from code.


for ex,
if session("age") <> ""
'Here is the block i want to get.
End if


Now can i set the session("age") to some value. and thus i can access the proceeding data.
__________________
dinesh s
  #8 (permalink)  
Old February 23rd, 2009, 08:26 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

If you mean that SESSION("age") is on one server and you want to change it from some unrelated server...NO! Of course not!

If *YOU* could do that then every hacker in the world would have long since wiped out all functioning ASP sites. That would be a security whole large enough to drive a steamship through!






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