المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : ie toolbar setting ******s



C# Programming
07-22-2009, 02:40 AM
Hello,

Here's what I'm trying to do. I need to create a toolbar that will post username/password to a webpage, get a ****** as response, and save that ****** so that the browser has access to it. Right now, I am able to send a post and save the response with the following code:

private bool get******()
{
HttpWebRequest request;
try
{
string dest = "http://" + ip;
string p = "username=un&password=pass";
MessageBox.Show("Sending a request to: " + dest + " with creds: " + p);

request = (HttpWebRequest)WebRequest.Create(dest);
request.******Container = ******Jar;

request.Credentials = CredentialCache.DefaultCredentials;

//Used to establish posting
request.Method = "POST";

Byte[] byte1 = Encoding.ASCII.GetBytes(p);

//Set the content type of the data being posted.
request.ContentType = "application/x-www-form-urlencoded";
//Set the content length of the string being posted.
request.ContentLength = byte1.Length;

Stream newStream = request.GetRequestStream();
newStream.Write(byte1, 0, byte1.Length);

newStream.Close();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
MessageBox.Show("Please ensure correct IP address.");
return false;
}

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

if (response.Headers["Set-******"] == null)
return false;

string[] cParams = response.Headers["Set-******"].Split('=');
string cName = cParams[0];
string cValue = cParams[1];
MessageBox.Show("****** name: " + cName + " Value: " + cValue);

my****** = new ******(cName, cValue);
my******.Expires = DateTime.Now.AddHours(1);

response.******s.Add(my******);
response.Close();

return r;
}


However, I do not think the ****** is being saved. Also, I don't really want to have it expire in 1 hour, I would prefer it to expire at end of session, but not sure how. I want the browser to have access to the ****** for future navigation. Essentially the toolbar logs the user in and performs the first query to the system. Future queries are likely to be done thru the web interface. I tried using an Http******, but I couldn't pass it to ******s.Add() since it wants a ****** and not Http******. I tried manually adding the ****** to the header of navigate/2 by:

string h = "******: name=value";
Object header = h;
navigate/2(url, null, null, null, header);

and it does add to the header, but the page does not log me in :/

Any help appreciated!

Mike

FREE 28 player online game @ http://www.1483online.com where the community drives enhancements to the game!