Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
using System;
using System.Configuration.Install;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.Remoting;
using System.ServiceProcess;
public class Service : System.ServiceProcess.ServiceBase {
private System.Timers.Timer m_tmr = new System.Timers.Timer(600000);//6 minutes
private System.ComponentModel.Container components = null;
public Service() {
this.InitializeComponent();
m_tmr.Elapsed +=new System.Timers.ElapsedEventHandler(m_tmr_Elapsed);
}
static void Main() {
ServiceBase[] ServicesToRun = new ServiceBase[] {new Service()};
ServiceBase.Run(ServicesToRun);
}
private void InitializeComponent() {
components = new System.ComponentModel.Container();
this.ServiceName = "Timed Service";
}
protected override void Dispose(bool disposing) {
if( disposing ) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
protected override void OnStart(string[] args) {
m_tmr.Enabled = true;
}
protected override void OnStop() {
m_tmr.Enabled = false;
}
private void m_tmr_Elapsed(object sender, System.Timers.ElapsedEventArgs e) {
//Do what you would do on your aspx page here
}
}
[RunInstaller(true)]
public class ServiceServiceInstaller : Installer {
private ServiceInstaller HostInstaller;
private ServiceProcessInstaller HostProcessInstaller;
public ServiceServiceInstaller() {
HostInstaller = new ServiceInstaller();
HostInstaller.StartType =
System.ServiceProcess.ServiceStartMode.Automatic;
HostInstaller.ServiceName = "Timed Service";
HostInstaller.DisplayName = "10 Minute Timed Service";
Installers.Add (HostInstaller);
HostProcessInstaller = new ServiceProcessInstaller();
HostProcessInstaller.Account = ServiceAccount.User;
Installers.Add (HostProcessInstaller);
}
}
private void m_tmr_Elapsed(object sender, System.Timers.ElapsedEventArgs e) {
//Do what you would do on your aspx page here
}
private void m_tmr_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
WebRequest req = null;
try
{
req = WebRequest.Create("[URL unfurl="true"]http://localhost/myweb/MyForm.aspx");[/URL]
req.Method = "GET";
req.Timeout = 20000; // seconds
}
catch (Exception ex)
{
}
}
private void m_tmr_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
WebRequest req = null;
WebResponse rsp = null;
StreamReader readStream = null;
string strRec="";
StringBuilder sb = new StringBuilder();
try
{
req = WebRequest.Create("[URL unfurl="true"]http://localhost/myweb/MyForm.aspx");[/URL]
req.Method = "GET";
req.Timeout = 20000;
rsp = req.GetResponse();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
readStream = new StreamReader( rsp.GetResponseStream(), encode );
Char[] read = new Char[256];
int count = readStream.Read( read, 0, 256 );
while (count > 0)
{
String str = new String(read, 0, count);
sb.Append(str);
count = readStream.Read(read, 0, 256);
}
strRec=sb.ToString();
sb=null;
}
catch (Exception ex)
{
}
}
<HEAD>
<title>Your Page Title Here</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="[URL unfurl="true"]http://schemas.microsoft.com/intellisense/ie5">[/URL]
[b]<%Response.AddHeader("Refresh","600");%>[/b]
</HEAD>