ASP.NET(C#) 定时执行一段代码
在Global.asax启动一条线程就ok了,下面是启动线程定时写文件的例子
Global.asax
C# code
Code
1<%@ Application Language="C#" %>
2<%@ Import Namespace="System.IO" %>
3<%@ Import Namespace="System.Threading" %>
4<script runat="server">
5 string LogPath;
6 Thread thread;
7 void WriteLog()
8 {
9 while (true)
10 {
11 StreamWriter sw = new StreamWriter(LogPath, true, Encoding.UTF8);
12 sw.WriteLine(thread.Name + ":" + DateTime.Now.ToString());
13 sw.Close();
14 Thread.CurrentThread.Join(1000 * 60);//阻止1分钟
15 }
16 }
17 void Application_Start(object sender, EventArgs e)
18 {
19 LogPath = HttpContext.Current.Server.MapPath("log.txt");
20 //在应用程序启动时运行的代码
21 thread = new Thread(new ThreadStart(WriteLog));
22 thread.Name = "写登录日志线程";
23 thread.Start();
24 }
25
26 void Application_End(object sender, EventArgs e)
27 {
28 //在应用程序关闭时运行的代码
29
30 }
31
32 void Application_Error(object sender, EventArgs e)
相关文档:
ASP.NET MVC的1.0发行说明
最新消息
ASP.NET MVC的1.0是ASP.NET MVC框架的第一个正式版本的支持。与往常一样,随时提供有关ASP.NET MVC的论坛反馈。
注意:在运行的ASP.NET MVC 1.0安装程序,卸载任何早期预ASP.NET MVC的发行版本。此外,关闭Visual Studio 2008的所有实例。
文档
ASP.NET MVC中的文件可在MSD ......
在ASP.NET 2.0 本地化技术之研究的回复中提到了以下两点:
1.这只是单个页面的切换,如何做整个站点的切换呢?( hjh )
2.关于如何将资源直接显示……既然控件能够将嵌入dll的资源直接显示,不知道网站能否也将嵌入资源直接调用WebResource显示呢?(Cat Chen )
由于不是一两句可以说清,所以再开一篇仔细 ......
首先在 Web.Config 中添加模拟帐号
<identity impersonate="true" userName="administrator"password="password" />
其次 要添加 EXCEL com 组件。如果是EXCEL2003,则添加 EXcel library 11.0 ......
最近发现语音验证码越来越流行,比如有次在注册gmail邮箱看到过,还有msn页面也有语音验证码,还有国外一些网站等。
花时间研究了下,语音验证码主要跟一般验证码的区别就在于如何让验证码播放。本文语音验证码原理:从服务器生成验证码,
并保存到cookie中(getcode.aspx.cs),当点收听验证码的时候,调用javascirpt操作 ......