
Originally Posted by
Rakuuza
Hello,
How would I be able to login to
MPGH via C# or even VB.Net. As I am trying to make a browser purely based on
MPGH and feature towards it, but at the moment to no avail can I get the login to work. I have located the code for everything else, but it's all useless since it can't do a remote login (eg. through the program and not navigating to the webpage)
I have tried so many methods of coding, from injecting a cookie to filling in the forms manually, but it doesn't help. Could I please get some help on this matter?
Thanks in advanced.
I suggest you to look on this:
HttpWebRequest Class (System.Net)
Code I found: (No credit to me, just found)
Code:
using System;
using System.Web;
using System.Net;
using System****;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Foo
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("Site");
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705;)";
req.Method = "POST";
req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
req.Headers.Add("Accept-Language: en-us,en;q=0.5");
req.Headers.Add("Accept-Encoding: gzip,deflate");
req.Headers.Add("Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7");
req.KeepAlive = true;
req.Headers.Add("Keep-Alive: 300");
req.Referer ="Site";
req.ContentType = "application/x-www-form-urlencoded";
String Username = "username";
String PassWord = "Password";
StreamWriter sw = new StreamWriter(req.GetRequestStream());
sw.Write("application=portal&url=" + Username + "&password=" + password + "");
sw.Close();
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string tmp = reader.ReadToEnd();
foreach (Cookie cook in response.Cookies)
{
tmp += "\n" + cook.Name + ": " + cook.Value;
}
Response.Write(tmp);
Response.End();
}
}
} You need to write it yourself tho