hi friends...
can u please tell me how to post a value to a site using C#?
for eg,
in an authentication page, the credentials are passed through posted variables. so the authentication page gets the values as follows.
string uid = Request['username"];
string pwd = Request["password"];
// code to validate credentials.
so, how can i post these variables to this page from anothre application?
i got these code from MSDN but it doesnt work for me.
string uri = "http://localhost/TestAuth/authenticate.aspx";
req = WebRequest.Create(uri);
req.Method = "POST"; // Post method
req.ContentType = "application/x-www-form-urlencoded"; // content type
Stream rs = req.GetRequestStream();
System.Text.ASCIIEncoding ae = new System.Text.ASCIIEncoding();
byte[] postdata = ae.GetBytes( "username=user|password=pwd");
rs.Write(postdata,0,postdata.Length);
rs.Close();
StreamReader rdr = new StreamReader(req.GetResponse().GetResponseStream());
Response.Write(rdr.ReadToEnd());
so what should i do?
thanking,
can u please tell me how to post a value to a site using C#?
for eg,
in an authentication page, the credentials are passed through posted variables. so the authentication page gets the values as follows.
string uid = Request['username"];
string pwd = Request["password"];
// code to validate credentials.
so, how can i post these variables to this page from anothre application?
i got these code from MSDN but it doesnt work for me.
string uri = "http://localhost/TestAuth/authenticate.aspx";
req = WebRequest.Create(uri);
req.Method = "POST"; // Post method
req.ContentType = "application/x-www-form-urlencoded"; // content type
Stream rs = req.GetRequestStream();
System.Text.ASCIIEncoding ae = new System.Text.ASCIIEncoding();
byte[] postdata = ae.GetBytes( "username=user|password=pwd");
rs.Write(postdata,0,postdata.Length);
rs.Close();
StreamReader rdr = new StreamReader(req.GetResponse().GetResponseStream());
Response.Write(rdr.ReadToEnd());
so what should i do?
thanking,