I am bit confused in using httpwebrequest. I tried to look into some articles but not able to get much from it as I am doing it for the first time. Below is the code I am trying to work on and I have few questions,
a) The ASPX page has few controls defined and in code-behind I create few controls. When I do httpwebrequest with POST, do I need to consider all controls and their values? I need to do POST for one of the controls only. Can I do it only for that control?
b) What URL should be specified in "(HttpWebRequest)WebRequest.Create"? I assume it is the same page that is shown to the user. For example in my example below it is ("http://localhost/MyIdentity/Confirm.aspx?ID=New&Designer=True&Colors=Yes");
c) Is there anything else I need to modify or take care of either in markup or code to achieve httpwebrequest?
private void OnPostInfoClick(object sender, System.EventArgs e)
{
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = ""; //Read from the stored array and print each element from the array loop here.
byte[] data = encoding.GetBytes(postData);
// Prepare web request...
HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create("http://localhost/MyIdentity/Confirm.aspx?ID=New&Designer=True&Colors=Yes");
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();
// Send the data.
newStream.Write(data, 0, data.Length);
newStream.Close();
}