Run URL without opening browser using C# and VB.Net in ASP.Net

Last Reply 2 months ago By dharmendr

Posted 2 months ago

How to call Web Application URL backgroundly if browser closed.

I want to run Web Application URL continuously even if web browser is not open on the machine.


Posted 2 months ago Modified on 2 months ago

Hi gauravs,

You have to use WebRequest or WebClient to call a url without opening the browser. Refer the below sample code.



using System.Net;
using System.IO;


Imports System.Net
Imports System.IO



protected void Page_Load(object sender, EventArgs e)
    string url = "";
    // Using WebRequest
    WebRequest request = WebRequest.Create(url);
    WebResponse response = request.GetResponse();
    string result = new StreamReader(response.GetResponseStream()).ReadToEnd();
    // Using WebClient
    string result1 = new WebClient().DownloadString(url);


Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    Dim url As String = ""
    ' Using WebRequest
    Dim request As WebRequest = WebRequest.Create(url)
    Dim response As WebResponse = request.GetResponse()
    Dim result As String = New StreamReader(response.GetResponseStream()).ReadToEnd()
    ' Using WebClient
    Dim result1 As String = New WebClient().DownloadString(url)
End Sub


I agree, here is the link: