TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Venu
NA
1
0
How to save Logon Credentials when browsing through different pages of the same site
Nov 24 2005 7:01 PM
I am logging in to a web site with the username and password,
It takes me to a web page where I post data to that web page and read the html text.
This works fine for the first time.
When I go to the webpage second time and try to post the data , It takes me to the login page again.
How can I retain the login to the website.
Basically I am losing the login information for the web site, it allows me to read the data after I am logged in for the first time, if I am clicking for some information on that page, it is directing me to the login page, how to avoid this? I have to retain the login information.
public System.IO.MemoryStream GetHttpStream()
{
int iRetryCount = 0;
HttpWebRequest request1 = (HttpWebRequest)WebRequest.Create(Url);
request1.CookieContainer = new CookieContainer();
HttpWebResponse response1 = (HttpWebResponse) request1.GetResponse();
string session = response1.Headers["Set-Cookie"];
response1.Close();
response1.Cookies = request1.CookieContainer.GetCookies(request1.RequestUri);
// System.Net.CookieCollection cookieCollection = new CookieCollection();
while (iRetryCount < this.retryCount | iRetryCount == 0)
{
try
{
request1 = (System.Net.HttpWebRequest) System.Net.WebRequest.Create(url);
request1.CookieContainer = this.CookieContainer;
System.Type methType = this.HttpMethod.GetType();
request1.Method = nav_utils.clsHTTPS.HttpMethodValues.GetName(methType, this.HttpMethod);
if(this.ProxyAddress!="" && this.ProxyAddress!=null)
{
System.Net.WebProxy myProxy = new System.Net.WebProxy(this.ProxyAddress, this.ProxyPort);
myProxy.BypassProxyOnLocal = true;
request1.Proxy = myProxy;
}
else
{
request1.Proxy = WebProxy.GetDefaultProxy();
}
if(this.Referer!="" && this.Referer!=null) request1.Referer = this.Referer;
certColl=request1.ClientCertificates;
request1.AllowAutoRedirect = this.allowAutoRedirect;
request1.ContentType=this.contentType;
request1.KeepAlive=this.keepAlive;
request1.Timeout = this.timeout;
request1.UserAgent = this.userAgent;
if(this.HttpMethod==HttpMethodValues.POST)
{
if(this.Headers.Count > 0) request1.Headers = this.Headers;;
System.IO.Stream sendStream;
byte [] bytes = null;
bytes = System.Text.Encoding.ASCII.GetBytes(this.PostParameters);
request1.ContentLength = bytes.Length;
sendStream = request1.GetRequestStream();
sendStream.Write(bytes,0,bytes.Length);
sendStream.Close();
}
if(this.Username!="" && this.Username!=null)
{
request1.Credentials = new System.Net.NetworkCredential(this.Username,this.Password);
}
response1 = (HttpWebResponse) request1.GetResponse();
System.IO.Stream stream = (System.IO.Stream)response1.GetResponseStream();
System.IO.MemoryStream ms = new System.IO.MemoryStream(ConvertStreamToByteBuffer(stream));
return ms;
}
catch (System.Net.WebException webE)
{
debugPrint(webE.Message);
debugPrint("Retry " + iRetryCount.ToString());
iRetryCount++;
for (int i = 0; i < this.retrySeconds; i++)
System.Threading.Thread.Sleep(1000);
}
finally
{
}
}
}
Reply
Answers (
0
)
Problem with events
Null function pointer... how do I do this in C#?