控制类满足要求
1:控制层必须要以Controller结尾
2:必须是非静态类
3:必须实现IController接口
4:方法一般以Action开始
VS2017添加MVC框架是在web一般处理程序中勾选上就行了。在调试阶段可以右键Views文件夹下边的视图实体文件,通过浏览器查看。
简单实例Demo
```csharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebApplication1.Controllers
{
public class UserController : Controller
{
// GET: User
public ActionResult Index()
{
return View(); //可以指定一个视图("视图名称")
}
public ActionResult UserLoad()
{
string strName = Request["uidName"] ?? "";
string strPwd = Request["pwdWord"] ?? "";
if (strName==strPwd)
{
return Content("ok");
}
return Content("file");
}
}
}
@{
Layout = null;
}
用户名: | |
密码: | |