How to call a URL or web address in Asp.net

Step 1. Add given namespaces

using System.Net;
using System.IO;

Step 2. Copy and paste given function in your .cs file

public void callurl(string url)
{
    WebRequest request = HttpWebRequest.Create(url);
    WebResponse response = request.GetResponse();
    StreamReader reader = new StreamReader(response.GetResponseStream());
    string urlText = reader.ReadToEnd(); // it takes the response from your url. now you can use as your need 
    Response.Write(urlText.ToString());
}

Step 3. Call this function like this as per as your requirement.

callurl("http://google.com");


Enjoy .net
Ebook Download
View all
Learn
View all