随笔分类 -  MVC

摘要:控制器ControllersControllers为控制器文档,AccountControllers内的方法对应View→Account下的cshtml文件。我们看到AcountControllers中包含两个Login方法。Login()为进入Login.cshtml后读取的第一个方法。Login(string UserName,string PassWord)为处理HttpPo... 阅读全文
posted @ 2014-07-25 04:56 Setme 阅读(482) 评论(0) 推荐(0)
摘要:_ViewStart.cshtml、_Layout.cshtml、Index.cshtml三个页面加载时候的先后顺序就是: _Layout.cshtml ViewStart.cshtml Index.cshtml 每个View下Controller对应的文件夹中,可以添加自己的_ViewStart.cshtml,用来指定独自使用的布局视图,采... 阅读全文
posted @ 2014-07-24 00:58 Setme 阅读(311) 评论(0) 推荐(0)
摘要:在Global.asax.cs文件中 protected void Application_BeginRequest(Object sender, EventArgs e) { Application["StartTime"] = System.DateTime.Now; } 再在webform1中的page_load事件中添加 ... 阅读全文
posted @ 2014-07-24 00:56 Setme 阅读(609) 评论(0) 推荐(0)
摘要:MVC 即模型视图控制器(Model View Controller) 利于团队开发、便于管理与维护。代码易读性强。未来的主流开发框架结构。 当然,缺点也显而易见,与传统开发框架相比有很大的不同。需要抛弃以前的观念来进行学习。 阅读全文
posted @ 2014-07-24 00:52 Setme 阅读(229) 评论(0) 推荐(0)
摘要:当我们利用Visual Studio生成实体类以后,难免会用到验证功能(例如,用户登录时验证用户名是否为空,并加以显示)。 Visual Studio实体类:实体类 如果直接去编辑Visual Studio生成的实体类话,当数据库更新字段后,再次更新实体类的话,会覆盖我们所添加的验证代码。 那么我们就要避免在Visual Studio生成的类中去进行代码的编写。这就需要用到扩展Model... 阅读全文
posted @ 2014-02-25 04:24 Setme 阅读(2215) 评论(0) 推荐(1)
摘要:阻止公共方法被调用 1 using System.Web.Mvc; 2 3 namespace MvcApplication1.Controllers 4 { 5 public class WorkController : Controller 6 { 7 [NonAction]//拒绝动作 8 public string ... 阅读全文
posted @ 2014-02-18 00:40 Setme 阅读(237) 评论(0) 推荐(0)