⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 global.asax

📁 Bug管理系统
💻 ASAX
字号:
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="btnet" %>
<%@ Assembly Src="util.cs"%>
<script runat="server" language="C#">

/*
Copyright 2002 Corey Trager 
Distributed under the terms of the GNU General Public License
*/

public void Log (String logMessage, TextWriter w)
{
	w.WriteLine(DateTime.Now.ToShortTimeString()
		+ logMessage);
	w.Flush(); 
}

 
public void Application_Error(Object sender, EventArgs e)
{

	Exception exc = Server.GetLastError().GetBaseException();

	bool log_enabled = (Util.get_setting("LogEnabled","1") == "1");
	if (log_enabled)
	{
		string log_file_folder = Util.get_setting("LogFileFolder","c:\\");
		DateTime now = DateTime.Now;
		string now_string = 
			Convert.ToString(now.Year)
			+ "_" +
			Convert.ToString(now.Month)
			+ "_" +
			Convert.ToString(now.Day);
		
		string path = log_file_folder
			+ "\\"
			+ "btnet_log_"
			+ now_string
			+ ".txt";
			
		// open file
		StreamWriter w = File.AppendText(path);
		
		w.WriteLine("\nTIME: "  + DateTime.Now.ToLongTimeString());
		w.WriteLine("MSG: " + exc.Message.ToString());
		w.WriteLine("URL: " + Request.Url.ToString());
		w.WriteLine("EXECPTION: " + exc.ToString());
		
		w.Close();
	}
	
	bool error_email_enabled = (btnet.Util.get_setting("ErrorEmailEnabled","1") == "1");
	if (error_email_enabled)
	{
		string to = Util.get_setting("ErrorEmailTo","");
		string from = Util.get_setting("ErrorEmailFrom","");
		string subject = "Error: " + exc.Message.ToString();
		string body = "\nTIME: "
			+ DateTime.Now.ToLongTimeString()
			+ "\nURL: "
			+ Request.Url.ToString()
			+ "\nException: "
			+ exc.ToString();

		Util.send_email(to, from, "", subject, body);				
	}
}
  

</script>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -