473,800 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Login to secure webpage using system.net.webc lient

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.asp x"

strPostData =
"UsernameTextBo x=username&Pass wordTextBox=123 4&LoginButton=L ogin"

'strPostData =
"__VIEWSTATE=dD wtNDU0NDA4NTk3O zs+hQAoe3316Ljm 9GtmhxCl3GsRZjw =&UsernameTextB ox=username&Pas swordTextBox=12 34&LoginButton= Login"

'login

gobjWebClient.H eaders.Add("Con tent-Type",
"applicatio n/x-www-form-urlencoded")

byteResponse = gobjWebClient.U ploadData(strUR L, "POST",
System.Text.Enc oding.ASCII.Get Bytes(strPostDa ta))

TextBox1.Text = System.Text.Enc oding.ASCII.Get String(byteResp onse)
Nov 21 '05 #1
1 3505
Hi,

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

Ken
-------------------------
"Ben" <Be*@NoSpam.com > wrote in message
news:%2******** ********@TK2MSF TNGP10.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.asp x"

strPostData =
"UsernameTextBo x=username&Pass wordTextBox=123 4&LoginButton=L ogin"

'strPostData =
"__VIEWSTATE=dD wtNDU0NDA4NTk3O zs+hQAoe3316Ljm 9GtmhxCl3GsRZjw =&UsernameTextB ox=username&Pas swordTextBox=12 34&LoginButton= Login"

'login

gobjWebClient.H eaders.Add("Con tent-Type",
"applicatio n/x-www-form-urlencoded")

byteResponse = gobjWebClient.U ploadData(strUR L, "POST",
System.Text.Enc oding.ASCII.Get Bytes(strPostDa ta))

TextBox1.Text = System.Text.Enc oding.ASCII.Get String(byteResp onse)

Nov 21 '05 #2

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

Similar topics

2
2322
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 version is: Dim myWebClient As New WebClient Dim nvc As New NameValueCollection nvc.Add("Login", username) nvc.Add("Password", password)
1
7919
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 programatically. The connection is not secure (not https, etc.). The login page just has simple name & password textboxes on it. Can someone please tell me how I can programatically login using the
1
1621
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 login page everytime. After I re-login, I can access the page. I can't figure out what happened. I saved the roles to the User so when I access another page, they should able to see that before they bounce me out.
2
1661
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 would we do this? this is how we are doing the login form ======= <authentication mode="Forms"> <forms loginUrl="/WebClient/SecurePages/logon.aspx" name="RSMNEmail" timeout="20" path="/"></forms>
14
7891
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 user in) and then redirect to the correct article. Here is the scenerio. If you are not logged into the site for certain articles you are
5
3792
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 webpage using ASP.net from another site (the url have parameters like (domain.com/?date=january) in it if that makes a difference) - using ASP.net code I want to Parse a table (perhaps using DomDocument object?) I want to retrieve data from...
0
12799
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 problem. I'm using this code in a ASP.NET 2.0 application just in case that matters, maybe someone knows a better way to do this?
0
1670
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 System.IO.FileStream(Server.MapPath(sSavePath + sFilename),System.IO.FileMode.Create,FileAccess.ReadWrite, FileShare.ReadWrite); newFile.Write(myData, 0, myData.Length); I'm using a fileupload control to select an image. now, when i'm running this page from my...
19
3306
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 (md5) the password field using a random one-time salt (nonce) -- generated by php and pasted in the form -- that is then posted with the hashed password
0
9691
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10505
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10276
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10253
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10035
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9090
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7580
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4149
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 we have to send another system

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.