源码参考:链接:http://pan.baidu.com/s/1pKhHHMj 密码:mkr4
1:新建-->项目-->Web-->ASP.NET MVC 4 Web 应用程序。命名为:Mvc4MicrosoftAjaxDemo
2:新建控制器:在Controllers文件夹上 右键-->添加-->控制器,命名为:HomeController (HomeController .cs)
3:在控制器HomeController中新增Action: GetDate()
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Threading; 5 using System.Web; 6 using System.Web.Mvc; 7 8 namespace Mvc4MicrosoftAjaxDemo.Controllers 9 { 10 public class HomeController : Controller 11 { 12 // 13 // GET: /Home/ 14 15 public ActionResult Index() 16 { 17 return View(); 18 } 19 20 public ActionResult GetDate() 21 { 22 //休眠1秒钟,监控前台动作 23 Thread.Sleep(1000); 24 return Content(DateTime.Now.ToString()); 25 } 26 } 27 }