c# - Programmatically logging in to a website -


How to enter the program on a website?

I just want to check that the username and the website provided is correct or not.

Thank you.

The easiest way to do this is to do something from .NET:

Using
  (var browser = new IE ("http://mysite.com")) {browser.TextField (Find.ByName ("email")). TypeText ("my@email.com"); Browser.TextField (Find.ByName ("password")) TypeText ("password") .; . Click on Browser.Button (Find.ByName ("Login to")) (); If (Browser. Content text ("Welcome my@email.com!")) {// Success}}  

To do this with HTTP Webbate, you want:

  var req = (HttpWebRequest) WebRequest.Create (url); Req.method = "POST"; Req.ContentLength = postContent.Length; Req.ContentType = "application / x-www-form-urlencoded"; (Var Stream Water = New Streamer (using req.GetRequestStream ()) {streamWriter.Write (postContent); } (Var res = (HttpWebResponse) using req.GetResponse ()) {_status = res.StatusCode; (Var Streamer = Using the new stream reader (res.GetResponsestream ()) (Response = streamReader.ReadToEnd ();}} Just add a third way, you can add webmail You can also use:  
  var nvc = new NameValueCollection (); Nvc.Add ("email", "my@email.com"); Nvc.Add ("password", "Password"); var wc = new WebClient (); byte [] responsesAre = wc.UploadValues ​​("http://mysite.com", nvc); String feedback text = encoding.ASCII.GetString (responseArray) ;  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -