Web Application URL

Last Reply 14 days ago By dharmendr

Posted 14 days 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.

 

You are viewing reply posted by: dharmendr 14 days ago.
Posted 14 days ago Modified on 14 days ago

Hi gauravs,

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

Namespaces

C#

using System.Net;
using System.IO;

VB.Net

Imports System.Net
Imports System.IO

Code

C#

protected void Page_Load(object sender, EventArgs e)
{
    string url = "http://www.aspforums.net/Threads/";
    // 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);
}

VB.Net

Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    Dim url As String = "http://www.aspforums.net/Threads/"
    ' 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: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html