I need to log into a site using asp.net web forms. I'm doing it this way. How could I redirect to the page after logging 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();
}