无畏的心

ASP.net. WF.net sql server javascript css

博客园 首页 新随笔 联系 订阅 管理

mvc3把传统的asp.net的aspx与cs的两种形式分成了三种:

1, view文件夹中的 .cshtml  文件 页面显示;

2, Controllers中的 .cs 文件 页面交互的方法;

3, Models中的 ,.cs实体类文件,为他们提供实体。

 

在controllers中的方法和view中的文件的名字相同。默认加载名字相同的方法。

页面传值。

局部刷新会使用 partialview和ajax 在方法上

 

首先要用Get的方法获取一个View,然后要用Post的方法接受提交的表单进行用户登录验证处理。
所以在Controller中会有两个Login action 但是这两个是不一样的,区别就在于GET和POST。
Get action 比较简单,如下:
        //
        // GET: /Account/Login/
        public ActionResult Login()
        {
            return View();
        }
POST action 比较复杂一些,要从Model模型中调用相应的功能,如下:
//
        // POST: /Account/Login
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Login(FormCollection collection)
        {
            try
            {
                string email = collection["email"];
                string password = collection["password"];
                password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password, "md5");

posted on 2014-05-17 19:24  c#路路通  阅读(64)  评论(0编辑  收藏  举报