1
I need to log into a website using the Asp.net web Forms. I am doing so. How could I redirect to the page after logged in?
protected void Button1_Click(object sender, EventArgs e)
{
var loginAddress = "http://sportone.sisguardiao.com.br/";
var loginData = new NameValueCollection
{
{ "LOGIN", "abfg" },
{ "SENHA", "123" }
};
Login(loginAddress, loginData);
}
public void Login(string loginPageAddress, NameValueCollection loginData)
{
CookieContainer container;
var request = (HttpWebRequest)WebRequest.Create(loginPageAddress);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
var buffer = Encoding.ASCII.GetBytes(loginData.ToString());
request.ContentLength = buffer.Length;
var requestStream = request.GetRequestStream();
requestStream.Write(buffer, 0, buffer.Length);
requestStream.Close();
container = request.CookieContainer = new CookieContainer();
var response = request.GetResponse();
response.Close();
}
Friend, could you give a hand with your great knowledge? I thank you!
– Harry