ASP.NET Tutorial/Development/HttpApplication — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 11:56, 26 мая 2010

Extends System.Web.HttpApplication

File: Global.asax
<%@ Application Language="C#" Inherits="Global"  %>

File:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public class Global : System.Web.HttpApplication
{
   public static int successRate = 50;
   protected void Application_Start(Object sender, EventArgs e)
   {
      WriteFile("Application Starting");
   }
   protected void Application_End(Object sender, EventArgs e)
   {
      WriteFile("Application Ending");
   }
   public void WriteFile(string strText)
   {
      System.IO.StreamWriter writer = new System.IO.StreamWriter(@"C:\Data.txt", true);
      string str;
      str = DateTime.Now.ToString() + "  " + strText;
      writer.WriteLine(str);
      writer.Close();
   }
   public static void StaticWriteFile(string strText)
   {
      System.IO.StreamWriter writer = new System.IO.StreamWriter(@"C:\Data.txt", true);
      string str;
      str = DateTime.Now.ToString() + "  " + strText;
      writer.WriteLine(str);
      writer.Close();
   }
}