WebRequest request = WebRequest.Create("http://google.com/");//Type url here
using (WebResponse response = request.GetResponse())
{
using (StreamReader responseReader =
new StreamReader(response.GetResponseStream()))
{
string responseData = responseReader.ReadToEnd();
string path= Server.MapPath(".");
if(!File.Exists(path+"//Asptrick.html"))
File.Create(path+"//Asptrick.html");
using (StreamWriter writer =
new StreamWriter(path + "//Asptrick.html")) //Where You Want to save Content
{
writer.Write(responseData);
}
}
}
use namespace for this as following:
using System.IO;
using System.Net;
using (WebResponse response = request.GetResponse())
{
using (StreamReader responseReader =
new StreamReader(response.GetResponseStream()))
{
string responseData = responseReader.ReadToEnd();
string path= Server.MapPath(".");
if(!File.Exists(path+"//Asptrick.html"))
File.Create(path+"//Asptrick.html");
using (StreamWriter writer =
new StreamWriter(path + "//Asptrick.html")) //Where You Want to save Content
{
writer.Write(responseData);
}
}
}
use namespace for this as following:
using System.IO;
using System.Net;