473,383 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Problem with website login

I am trying to get this application to login in order to gather specific data from within the members area. This is the first time I have done this and I am not sure whats wrong.

The site passes the login like this:
http://www.example.com/Ajax/Users_Login.asp?UserName=NAME&UserPsw=PASS&Remembe rMe=1&LogInLocation=0&BackUrl=0

When this page is loaded it displays a xml file with a welcome message. When I retrieve the requested page it acts like it was not logged in. Any help would be greatly appreciated!

Expand|Select|Wrap|Line Numbers
  1.             string loginUri = "http://www.example.com/Ajax/Users_Login.asp";
  2.             string loginData = "?UserName=NAME&UserPsw=PASS&RememberMe=1&LogInLocation=0&BackUrl=0";
  3.             string requestUri = "http://www.example.com/";
  4.             CookieContainer cookieContainer = new CookieContainer();
  5.             HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(loginUri);
  6.             req.CookieContainer = cookieContainer;
  7.             req.Method = "POST";
  8.             req.ContentType = "application/x-www-form-urlencoded";
  9.             ASCIIEncoding encoding = new ASCIIEncoding();
  10.             byte[] loginDataBytes = encoding.GetBytes(loginData);
  11.             req.ContentLength = loginDataBytes.Length;
  12.             Stream stream = req.GetRequestStream();
  13.             stream.Write(loginDataBytes, 0, loginDataBytes.Length);
  14.             stream.Close();
  15.             HttpWebResponse res = (HttpWebResponse)req.GetResponse();
  16.  
  17.             req = (HttpWebRequest)HttpWebRequest.Create(requestUri);
  18.             req.CookieContainer = cookieContainer;
  19.             req.Method = "GET";
  20.             res = (HttpWebResponse)req.GetResponse();
  21.             StreamReader sr = new StreamReader(res.GetResponseStream());
  22.             textBox1.Text = sr.ReadToEnd();
  23.  
Dec 27 '10 #1
0 1006

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

Similar topics

0
by: Lance | last post by:
I need help with having a Login Form on a website that goes to a member only section, to beable to check my forum database so that when people register, they register on my forum, and at the same...
1
by: John | last post by:
Hi I have placed a login control on a web form. When I run the webform and click on the login button with dummy username & password, I get the following error; Exception Details:...
1
by: EricRybarczyk | last post by:
I am starting a rewrite of an existing Classic ASP web site in ASP.NET 2.0. The existing ASP application has several types of users, each with a separate login process (separate login page,...
2
by: Tom | last post by:
I hope someone can help me figure out what's going on here. I've re-read the section on sessions at php.net and Googled this high and low but I haven't found anything that quite explains my...
0
by: John Meyer | last post by:
index: <%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.OleDb" %> <!DOCTYPE html PUBLIC...
1
by: luketongue | last post by:
Hi, I am building a website that allows you to login at any time to access specfic user information etc .. In the past i have always used form authentication to lock down any protected areas and...
4
by: suruchimathur | last post by:
Hi, I need to write a perl script to browse a certain site, login and click on a link. The URL for the link changes daily and uses session ID as well but the text remains the same on the HTML page....
2
by: KBuser | last post by:
Looking for somebody to help me for an hour or two (I doubt it will be that long). Basically I can't get the url encoding to work properly in my program, so I need you to write a method which will...
1
by: SkyGringo | last post by:
Hi, I'm using the 64-bit version of SQL Server 2005, SP2, on Windows Server 2003 R2 X64 Enterprise Edition. I've got a bunch of users out there who are the db_owner, db_accessadmin and...
2
by: sheaguevara | last post by:
This is my first post onto the forum. So first off, I'd like to say hello to everyone. I just started working on a login/registration system and I am trying to have a feature where the user will...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.