0% found this document useful (0 votes)
44 views

Frmweb Request

Namespace frmwebRequest public partial class Form1 : form public initializeComponent(); private void button1_Click(object sender, EventArgs e); using System.collections.generic; using System.componentmodel; using system.drawing; using sys.linq; using systems.windows.forms; using.net; namespace frmwebrequest;. Using System.Collections

Uploaded by

santhosh1212
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Frmweb Request

Namespace frmwebRequest public partial class Form1 : form public initializeComponent(); private void button1_Click(object sender, EventArgs e); using System.collections.generic; using System.componentmodel; using system.drawing; using sys.linq; using systems.windows.forms; using.net; namespace frmwebrequest;. Using System.Collections

Uploaded by

santhosh1212
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

webBrouser1

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
namespace frmwebRequest
{
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
WebRequest request = WebRequest.Create(textBox1.Text);//to create
the web request
request.Credentials = CredentialCache.DefaultCredentials;//to
provide default credentials
HttpWebResponse response =
(HttpWebResponse)request.GetResponse();//the response shoulb in http form
//so convert it in
httpwebresponse and store it in resopnse
MessageBox.Show(response.StatusDescription);//to provide the
status--if download starts status is "ok"

Stream datastream = response.GetResponseStream();


StreamReader reader = new StreamReader(datastream);
string responseFromServer = reader.ReadToEnd();
MessageBox.Show(responseFromServer);
webBrowser1.DocumentText = responseFromServer;

reader.Close();
datastream.Close();
response.Close();
}
}
}

You might also like