2010-12-17 9 views
0

Ich habe eine Desktop-Anwendung in asp.net mit C#, die Verbindung mit remote-server.Ich bin in der Lage zu verbinden, aber wie zeige ich, dass meine Anmeldung erfolgreich ist oder nicht. Danach möchte ich Daten vom Remote-Server abrufen .......... so plz hilf mir.Ich habe den untenstehenden Code geschrieben .............. ist da noch etwas besser WegWie bekomme ich Antwort von Remote-Server

try 
     { 

      string strId = UserId_TextBox.Text; 
      string strpasswrd = Password_TextBox.Text; 

      ASCIIEncoding encoding = new ASCIIEncoding(); 
      string postData = "UM_email=" + strId; 
      postData += ("&UM_password=" + strpasswrd); 
      byte[] data = encoding.GetBytes(postData); 
      MessageBox.Show(postData); 
      // Prepare web request... 
      //HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://localhost/ruhit/basic_framework/index.php?menu=login=" + postData); 
     HttpWebRequest myRequest =(HttpWebRequest)WebRequest.Create("http://www.facebook.com/login.php=" + postData); 
      myRequest.Method = "POST"; 
      myRequest.ContentType = "application/x-www-form-urlencoded"; 
      myRequest.ContentLength = data.Length; 


      Stream newStream = myRequest.GetRequestStream(); 
      // Send the data. 
      newStream.Write(data, 0, data.Length); 
      MessageBox.Show("u r now connected"); 
      HttpWebResponse response = (HttpWebResponse)myRequest.GetResponse(); 
      // WebResponse response = myRequest.GetResponse(); 

      StreamReader reader = new StreamReader(response.GetResponseStream()); 

      string str = reader.ReadLine(); 
      while (str != null) 
      { 
      str = reader.ReadLine(); 
      MessageBox.Show(str); 
      } 
      reader.Close(); 
      newStream.Close(); 

     } 
     catch 
     { 
      MessageBox.Show("error connecting"); 
     } 

Antwort

Verwandte Themen