473,568 Members | 2,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.Net System.Net - Cookies - Form Submit

IonutZ
7 New Member
Hi guys,

This is what I'm trying to achieve:
  • Login to Facebook via system.net

I've already achieved login through AxWebBrowser... but then I don't know how to disable sound / images / javascript and I occasionally get a JS error which is not cool...

But via System.NET I don't know how to work with cookies... This is what I've got so far (where I'm stuck)


Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Dim web As New System.Net.WebClient()
  3.     Dim james As New System.Net.Cookie
  4.  
  5.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  6.  
  7.         web.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
  8.         web.Headers.Add(Net.HttpRequestHeader.UserAgent, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)")
  9.  
  10.         Dim d As Byte() = System.Text.Encoding.ASCII.GetBytes("email=SOMEEMAILADDRESS@comcast.net")
  11.  
  12.         Dim res As Byte() = web.UploadData("https://login.facebook.com/login.php", "POST", d)
  13.  
  14.         txtCool.text = System.Text.Encoding.ASCII.GetString(res)
  15.     End Sub
  16.  
  17. End Class
  18.  
This is how the cookie IE7 makes, looks like:

Expand|Select|Wrap|Line Numbers
  1. __qca
  2. 1172665088-900161-52902507
  3. facebook.com/
  4. 1600
  5. 2350186496
  6. 32111674
  7. 2186409104
  8. 29842226
  9. *
  10. login
  11. ionutz%40comcast.net
  12. facebook.com/
  13. 9728
  14. 1022930048
  15. 29867537
  16. 744132816
  17. 29844254
  18. *
  19.  
This was much easier in VB 6, but I decided to step it up and try to do it in VB.Net...

What I don't know how to do:
  • Add more variables to the post string
  • How to show facebook through system.net that I "have cookies enabled"
  • How to login haha


And as you can tell, SOMEEMAILADDRES S@comcast.net is my e-mail... so if anyone could help, i'd be super-thankful.

The purpose of this program is - pure personal use, I want to make a program that checks for messages on facebook at a given interval of time and will warn me when I get one!

Thanks and looking forward to your reply!
Mar 10 '07 #1
6 9390
AricC
1,892 Recognized Expert Top Contributor
Hi guys,

This is what I'm trying to achieve:
  • Login to Facebook via system.net

I've already achieved login through AxWebBrowser... but then I don't know how to disable sound / images / javascript and I occasionally get a JS error which is not cool...

But via System.NET I don't know how to work with cookies... This is what I've got so far (where I'm stuck)


Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Dim web As New System.Net.WebClient()
  3.     Dim james As New System.Net.Cookie
  4.  
  5.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  6.  
  7.         web.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
  8.         web.Headers.Add(Net.HttpRequestHeader.UserAgent, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)")
  9.  
  10.         Dim d As Byte() = System.Text.Encoding.ASCII.GetBytes("email=SOMEEMAILADDRESS@comcast.net")
  11.  
  12.         Dim res As Byte() = web.UploadData("https://login.facebook.com/login.php", "POST", d)
  13.  
  14.         txtCool.text = System.Text.Encoding.ASCII.GetString(res)
  15.     End Sub
  16.  
  17. End Class
  18.  
This is how the cookie IE7 makes, looks like:

Expand|Select|Wrap|Line Numbers
  1. __qca
  2. 1172665088-900161-52902507
  3. facebook.com/
  4. 1600
  5. 2350186496
  6. 32111674
  7. 2186409104
  8. 29842226
  9. *
  10. login
  11. ionutz%40comcast.net
  12. facebook.com/
  13. 9728
  14. 1022930048
  15. 29867537
  16. 744132816
  17. 29844254
  18. *
  19.  
This was much easier in VB 6, but I decided to step it up and try to do it in VB.Net...

What I don't know how to do:
  • Add more variables to the post string
  • How to show facebook through system.net that I "have cookies enabled"
  • How to login haha


And as you can tell, SOMEEMAILADDRES S@comcast.net is my e-mail... so if anyone could help, i'd be super-thankful.

The purpose of this program is - pure personal use, I want to make a program that checks for messages on facebook at a given interval of time and will warn me when I get one!

Thanks and looking forward to your reply!
I edited your post providing your email address in that format is a great way to get spammed.
Mar 11 '07 #2
IonutZ
7 New Member
I edited your post providing your email address in that format is a great way to get spammed.
Thanks, didn't realize this site was spidered, but then, I got to it by googling.... so - it makes sense =)
Mar 11 '07 #3
IonutZ
7 New Member
bumpity bump bump
opyo
o s
s t
t
Mar 12 '07 #4
kenobewan
4,871 Recognized Expert Specialist
Here is an article that may help:
ASP.NET Cookies
Mar 12 '07 #5
IonutZ
7 New Member
Nope, that doesn't really help because I'm trying to extract / emulate a cookie with the webclient .net component...

Thanks tho... anyone have any other ideas?
Mar 12 '07 #6
kenobewan
4,871 Recognized Expert Specialist
Here is a post trying to do something similar:
WebClient timeout

While this is not helpful either, I believe it illustrates a difference between VB6 & vb.net in trying to manage sessionstate for the project. In relation to webclient, I believe that there is class and not a component - unless you create one using the class. Here is an example:
Screen Scrapes in ASP.NET

So I don't believe that you can directly migrate a VB6 webclient component to asp.net the way that you would like. That is why the earlier article I referenced referred you to the handling of sessionstate through cookies. Here is an article that may prove me wrong:
Download a Web Page using the WebClient

I hope that this is helpful.
Mar 13 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2738
by: victor | last post by:
Hi, I used Cookies to store username. In a Windows98 client, I typed some Chinese characters into the login box in login.asp. After submit, in c.asp, the username is stored in the cookies. The original username and the one got back from the cookies are displied in c.asp, they are different! Use WindowsXP client will be fine.
20
3533
by: Brian Burgess | last post by:
Hi all, Anyone know if this is possible? If so, on which page would the cookie be? .. On the page calling a function defined in the include file? thanks in advance.. -BB
7
2988
by: Brian Burgess | last post by:
Hi all, Anyone see anything wrong with the following: *************************************************************** <%@ LANGUAGE="VBSCRIPT" %> <% Option Explicit Dim nAcctNbr Dim nMsgStart
0
1491
by: collie | last post by:
i need to create 2 separate cookies in asp to be read later on in asp.net. I need to create an ADMIN cookie and a User cookie. In my database i have a table called users. if the field ACCESS=admin then i need to create an admin cookie if ACCESS =user then i need to create a user cookie. The page is redirected to an aspx page where it reads the...
4
5377
by: Fred | last post by:
Hi, i know how to pass a value from Javascript to ASP with a hidden field into a form and submitting it, or with cookies, but here i have to pass a lot of data in an array. There is a list of product the visitor can order by clicking one or more checkboxes. I made a form containing input with type "checkbox" like: <form> <input...
2
6949
by: Luis Esteban Valencia Muñoz | last post by:
I'm working on a web scraping application that needs to log into a website before it can get the data to scrape. I've always been confused about how the HttpWebRequest and HttpWebResponse objects work together with cookies, and was hoping that someone here could clear it up for me! Here's the steps I need to accomplish: 1) Set two...
6
6437
by: Paul | last post by:
Here is a question that should get everyone going. I have an ecommerce site where I need to pass the order_id to every page. So which method is the best practice to pass this variable between pages: Cookies or Session variable or by the HTTP header (either GET querystring or POST form)? I do not like to use sessions because they time out...
0
1703
by: Claudio | last post by:
I have a demo app where cookies does not work. The first page create a cookies. The second read the contet. If I browse the pages via IE6.0 the pages does not work. If I browse the pages via FireFox the pages work fine. ************ SetCookies.asp <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01...
4
2770
by: Jon Slaughter | last post by:
I have developed a technique to add and remove cookies after output... wondering if there is something else like this out there? Jon
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7916
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8117
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6275
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5498
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
932
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.