المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Looking for help in querying web page values with C sharp



C# Programming
09-20-2013, 08:12 PM
I am very familiar with C sharp, but have not ever tried to do anything with Aspx/Silverlight and c sharp, so I'm a totally new to that.

For an exercise, I would like to query the company time entry website (Aspx and Silverlight on the front end), specifically the vacation hours value with a test form in C sharp.

Besides login credentials and the url, what do I need for this and how can I do this? I tried the code below, but it did not do anything.

Thanks for reading.


private void btnTest_Click(object sender, EventArgs e) { try { // Create a request for the URL. WebRequest request = WebRequest.Create ( "https://time.website.com/pa/application.aspx#/TimesheetEntry"); // If required by the server, set the credentials. request.Credentials = new System.Net.NetworkCredential("username", "password", "domain"); //request.Credentials = CredentialCache.DefaultCredentials; // Get the response. WebResponse response = request.GetResponse (); // Display the status. lbxValues.Text += ((HttpWebResponse)response).StatusDescription; //Console.WriteLine(((HttpWebResponse)response).StatusDescription); // Get the stream containing content returned by the server. Stream dataStream = response.GetResponseStream (); // Open the stream using a StreamReader for easy access. StreamReader reader = new StreamReader (dataStream); // Read the content. string responseFromServer = reader.ReadToEnd (); // Display the content. lbxValues.Text += (responseFromServer); //Console.WriteLine (responseFromServer); // Clean up the streams and the response. reader.Close (); response.Close (); } catch (Exception ex) { MessageBox.Show(ex.Message + System.Environment.NewLine + ex.Source + System.Environment.NewLine + ex.TargetSite + System.Environment.NewLine + ex.StackTrace + System.Environment.NewLine + System.Environment.NewLine); } }