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();
}
Ïà¹ØÎĵµ£º
ÔÚwindows 2003ÏÂ,ÔÚÔËÐÐwebÓ¦ÓóÌÐòµÄʱºò³öÏÖһϴíÎó:
·þÎñÆ÷ÎÞ·¨´¦ÀíÇëÇ󣬣££¾¶Ô·¾¶“C:\temp\mytest.txt”µÄ·ÃÎʾܾø
˵Ã÷: Ö´Ðе±Ç° Web ÇëÇóÆÚ¼ä£¬³öÏÖδ´¦ÀíµÄÒì³£¡£Çë¼ì²é¶ÑÕ»¸ú×ÙÐÅÏ¢£¬ÒÔÁ˽âÓйظôíÎóÒÔ¼°´úÂëÖе¼Ö´íÎóµÄ³ö´¦µÄÏêϸÐÅÏ¢¡£
Òì³ ......
µÚÒ»£º
C# code
private void Button1_Click( object sender, System.EventArgs e )
{
Response.Redirect( Request.Url.ToString( ) );
}
µÚ¶þ£º
C# code
private void Button2_Click( object sender, System.EventArgs e )
{
Response.Write( " < script language=javascript>window.location.h ......
¿´¹ý΢ÈíµÄÍøÕ¾ÓÐʱºò£¬ÊÇ.MSPXµÄÀ©Õ¹Ãû£¿ÆäʵÄãÒ²¿ÉÒÔÅäÖ㬺ܼòµ¥¡£Here We Go!
ÅäÖÃWEB.CONFIG£º
<system.web>
<compilation>
<buildProviders>
<add ......
protected void Page_Load(object sender, EventArgs e)
...{
this.btnOK.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(btnOK, "Click") + ";this.disabled=true; this.value='Ìá½»ÖÐ...';");
}
//°´Å¥´¦Àí·½·¨
protected void btnOK_C ......