Query from an internal network

Sep 16 2018 4:58 AM
 
Dear,

I would like a query on a internal network tool about a internal url like "http://192.168.1.10:5000" and write the result in a RichTextBox or write it in a text-file.
I have mak a sample, but it does not run.
I get in the sample an exeption on line 26. "WebResponse response = request.GetResponse();"

I don't no where ist the problem?
Please, could help me anyone?
 
I have a form with
- textBox1.Texthttp://192.168.1.10:5000
- richTextBox
and a button
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Data;  
  5. using System.Drawing;  
  6. using System.Linq;  
  7. using System.Text;  
  8. using System.Threading.Tasks;  
  9. using System.Windows.Forms;  
  10. using System.Net;  
  11. using System.IO;  
  12.   
  13. namespace Http_Webabfrage_1  
  14. {  
  15.     public partial class Form1 : Form  
  16.     {  
  17.         public Form1()  
  18.         {  
  19.             InitializeComponent();  
  20.         }  
  21.   
  22.         private void button1_Click(object sender, EventArgs e)  
  23.         {  
  24.             string URL = textBox1.Text;  
  25.             WebRequest request = WebRequest.Create(URL);  
  26.             WebResponse response = request.GetResponse();  
  27.             StreamReader reader = new StreamReader(response.GetResponseStream());  
  28.             string str = reader.ReadLine();  
  29.             while (str != null)  
  30.             {  

  31.                 richTextBox1.Text = str;
  32.             }  
  33.         }  
  34.     }  

 

Answers (2)