微软提供了4中过滤器: 1.Action过滤器: 在Action方法执行之前和Action方法执行之后, 会执行此过滤器中的代码. 比如在执行public ActionResult Index()方法之前或之后; 也可以说是在方法执行前或执行后; 接口: IactionFilter 抽象类名: Ac ...
分类:
Web程序 时间:
2017-02-19 00:22:15
阅读次数:
686
public ActionResult GetDateTime(string userName,int age) { System.Threading.Thread.Sleep(2000); return Content(DateTime.Now.ToString() + userName + ag... ...
分类:
Web程序 时间:
2017-02-17 23:43:19
阅读次数:
313
创建角色管理相关视图 1、添加视图 打开RolesAdminController.cs 将鼠标移动到public ActionResult Index()上 右键》添加视图 系统会弹出对话框 什么也不用改 直接“确定”。 2、在创建的视图上添加数据模型 在第一行添加 @model IEnumerab ...
分类:
Web程序 时间:
2017-02-13 00:10:53
阅读次数:
383
创建用户管理相关视图 1、添加视图 打开UsersAdminController.cs 将鼠标移动到public ActionResult Index()上 右键》添加视图 系统会弹出对话框 什么也不用改 直接“添加”。 2、在创建的视图上添加数据模型 在第一行添加 @model IEnumerab ...
分类:
Web程序 时间:
2017-02-12 18:45:27
阅读次数:
218
public ActionResult Create() { return View(); } [HttpPost] public ActionResult Create(Books book) { book.CreateDate = DateTime.Now; ... ...
分类:
Web程序 时间:
2017-02-07 16:33:25
阅读次数:
275
public ActionResult Upload(HttpPostedFileBase Namefile) { //判断文件是否存在 if (Namefile == null) { return Content("没有文件"); } //获取上传文件的名称,位置 var fileName = D ...
分类:
数据库 时间:
2017-01-22 17:48:22
阅读次数:
280
使用NPOI进行导出Excel表格大家基本都会,我在网上却很少找到导出Excel表格并提示下载的 简单的代码如下 1 //mvc项目可以传多个id以逗号相隔的字符串 2 public ActionResult execl(string ids) 3 { 4 List<PayLog> list = n ...
分类:
数据库 时间:
2017-01-10 13:14:50
阅读次数:
222
前言 在WEB中,经常要使用到将数据转换成EXCEL,并进行下载。这里整理资料并封装了一个自定义ActionResult类,便于使用。如果文章对你有帮助,请点个赞。 话不多少,这里转换EXCEL使用的NPOI。还是用了一下反射的知识,便于识别实体类的一些自定义特性。 一、自定义一个Attribute ...
程序代码 [HttpPost]public ActionResult Edit(Person person){ if (ModelState.IsValid) { Person oldperson = db.People.Where(p => p.Id == person.Id).FirstOrDe ...
分类:
其他好文 时间:
2016-12-06 20:42:21
阅读次数:
134
中心思想就是在一个表单内不规定”action“,在js里面用@Url.Axtion("视图层","控制器")方法来设置表单的传值。 控制器 public ActionResult Jia(string a1, string a2) { int end = Convert.ToInt32(a1) + ...
分类:
Web程序 时间:
2016-12-06 14:25:11
阅读次数:
190