asp.net¶¨Ê±Ö´ÐдúÂë
string LogPath;
Thread thread;
void WriteLog()
{
while (true)
{
StreamWriter sw = new StreamWriter(LogPath, true, Encoding.UTF8);
sw.WriteLine(thread.Name + ":" + DateTime.Now.ToString());
sw.Close();
Thread.CurrentThread.Join(1000 * 60);//×èÖ¹1·ÖÖÓ
}
}
void Application_Start(object sender, EventArgs e)
{
LogPath = HttpContext.Current.Server.MapPath("log.txt");
//ÔÚÓ¦ÓóÌÐòÆô¶¯Ê±ÔËÐеĴúÂë
thread = new Thread(new ThreadStart(WriteLog));
thread.Name = "дµÇ¼ÈÕÖ¾Ïß³Ì";
thread.Start();
}
Ïà¹ØÎĵµ£º
±¾ÎĽ«ÌÖÂÛ.NETµÄÓ¦ÓóÌÐòÓò£¬²¢ÇÒËüÃÇÊÇÈçºÎ¶ÔASP.NETµÄÖ´Ðк͵÷¶È²úÉúÓ°ÏìµÄ¡£
¡¡¡¡µ±ÔÚWindowsÖÐÆô¶¯Notepad³ÌÐòʱ£¬ÖÚËùÖÜÖª³ÌÐò»áÖ´ÐÐÒ»¸ö°üº¬ÔÚÈÝÆ÷ÄڵĽø³Ì¡£¿ÉÒÔÆô¶¯¶à¸öNotepadµÄʵÀý£¬²¢ÇÒÿ¸öʵÀý¶¼»áÔÚÒ»¸öרעµÄ½øÐгÌÔËÐС£Ê¹ÓÃÈÎÎñ¹ÜÀíÆ÷£¬¿ÉÒÔ¿´µ½ÔÚϵͳÖе±Ç°ÔËÐÐ ......
ÔÚwindows 2003ÏÂ,ÔÚÔËÐÐwebÓ¦ÓóÌÐòµÄʱºò³öÏÖһϴíÎó:
·þÎñÆ÷ÎÞ·¨´¦ÀíÇëÇ󣬣££¾¶Ô·¾¶“C:\temp\mytest.txt”µÄ·ÃÎʾܾø
˵Ã÷: Ö´Ðе±Ç° Web ÇëÇóÆڼ䣬³öÏÖδ´¦ÀíµÄÒì³£¡£Çë¼ì²é¶ÑÕ»¸ú×ÙÐÅÏ¢£¬ÒÔÁ˽âÓйظôíÎóÒÔ¼°´úÂëÖе¼Ö´íÎóµÄ³ö´¦µÄÏêϸÐÅÏ¢¡£
Òì³ ......
package com.accp.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.H ......
ÔÚÔçÆÚѧϰc#µÄ¹ý³ÌÖУ¬¾³£Óöµ½ÕâÑùµÄÓï¾ä£º
public string StudentName
{
get{return stuName;}
set{stuName=value;}
}
µ±Ê±Ò²²»ÊǺÜÃ÷°×ΪʲôҪÕâÑù£¿Ñ§ÉîÁËc#ºó£ ......