473,513 Members | 2,406 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Login to secure webpage using system.net.webclient

Ben
Hi

I have the code below that I am using to login to my remote webpage.

The problem is that it seems to not post the data. I have heard that
ViewState can be a problem and that it may be necessary to retrieve the
ViewState field and Post it with the data, i have attempted test this by
copying the viewstate text out of the source and into the start of the
variable strPostData - as you can see commented out.

I am unsure why I do not get forwarded from the adminlogin.aspx page after
posting the data, could this be the viewstate or another issue?

Any advice would be much appreciated.

Thanks
B
Dim strURL As String
Dim strPostData As String

Dim byteResponse() As Byte

Dim i As Integer

Dim strViewState As String

strURL = strHttpLocation & "adminlogin.aspx"

strPostData =
"UsernameTextBox=username&PasswordTextBox=1234&Log inButton=Login"

'strPostData =
"__VIEWSTATE=dDwtNDU0NDA4NTk3Ozs+hQAoe3316Ljm9Gtmh xCl3GsRZjw=&UsernameTextBox=username&PasswordTextB ox=1234&LoginButton=Login"

'login

gobjWebClient.Headers.Add("Content-Type",
"application/x-www-form-urlencoded")

byteResponse = gobjWebClient.UploadData(strURL, "POST",
System.Text.Encoding.ASCII.GetBytes(strPostData))

TextBox1.Text = System.Text.Encoding.ASCII.GetString(byteResponse)
Nov 21 '05 #1
1 3481
Hi,

http://msdn.microsoft.com/library/de...tialstopic.asp

Ken
-------------------------
"Ben" <Be*@NoSpam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi

I have the code below that I am using to login to my remote webpage.

The problem is that it seems to not post the data. I have heard that
ViewState can be a problem and that it may be necessary to retrieve the
ViewState field and Post it with the data, i have attempted test this by
copying the viewstate text out of the source and into the start of the
variable strPostData - as you can see commented out.

I am unsure why I do not get forwarded from the adminlogin.aspx page after
posting the data, could this be the viewstate or another issue?

Any advice would be much appreciated.

Thanks
B
Dim strURL As String
Dim strPostData As String

Dim byteResponse() As Byte

Dim i As Integer

Dim strViewState As String

strURL = strHttpLocation & "adminlogin.aspx"

strPostData =
"UsernameTextBox=username&PasswordTextBox=1234&Log inButton=Login"

'strPostData =
"__VIEWSTATE=dDwtNDU0NDA4NTk3Ozs+hQAoe3316Ljm9Gtmh xCl3GsRZjw=&UsernameTextBox=username&PasswordTextB ox=1234&LoginButton=Login"

'login

gobjWebClient.Headers.Add("Content-Type",
"application/x-www-form-urlencoded")

byteResponse = gobjWebClient.UploadData(strURL, "POST",
System.Text.Encoding.ASCII.GetBytes(strPostData))

TextBox1.Text = System.Text.Encoding.ASCII.GetString(byteResponse)

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2305
by: Gill Bates | last post by:
I'm trying to login to a banking site (https://www.providentconnection.com) using vb.net. I've tried many variations of WebClient and HttpWebRequest; none of which I've got to work. My latest...
1
7873
by: Tom Jones | last post by:
Hi, I am using the HttpWebRequest and HttpWebResponse classes to pull information from a web server on the internet. I have an account on one of the webservers that I need to log into...
1
1612
by: Homa | last post by:
Hi, I am using a role-based Forms Authentication. I have several directories that have different levels of authorization. When I try to access another directory, the page bounce me back to the...
2
1635
by: Brian Henry | last post by:
We have our windows forms login set up and working good, well it works at least, just now we need a logout button, so when you click on it, the user will be logged out of the authentication, how...
14
7864
by: n8 | last post by:
Hi, Hi have to do the followign and have been racking my brain with various solutions that have had no so great results. I want to use the System.Net.WebClient to submit data to a form (log a...
5
3781
by: news.microsoft.com | last post by:
Hi again, I am pretty new to ASP.net (I use to be a Visual Basic 6 addict) I want to do the following but I have been unable to find good info/ or sample code on it; please help; - retrieve a...
0
12752
by: barrybevel | last post by:
Hi, I'm trying to login to the www.vodafone.ie website using HttpWebRequest. It works fine with IE/Firefox and the .NET Web Control too, just not with my code. I think it's a redirect 302...
0
1656
by: rohitscripts | last post by:
I'm uploading an image from my aspx page to a folder(not in database) in ftp server using the following code:: System.IO.FileStream newFile = new...
19
3272
by: klenwell | last post by:
Another request for comments here. I'd like to accomplish something like the scheme outlined at this page here: http://tinyurl.com/3dtcdr In a nutshell, the form uses javascript to hash...
0
7264
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,...
0
7166
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7543
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...
1
7106
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5689
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,...
0
3236
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...
0
3226
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1601
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.