mvc的知识过滤器可以自己查找,这里只是简单demo。
新建项目,添加引用
首先新建4.5框架的web应用空程序。创建好后,进入包控制台,执行命令来添加两个关键引用:
install-package microsoft.aspnet.mvc.zh-hans
install-package microsoft.aspnet.Web.Optimization.zh-hans
项目结构如图
在global.asax文件种配置一个路由用于请求。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.Mvc;
using System.Web.Routing;
namespace LoginAttributeDemo
{
public class Global : System.Web.HttpApplication
{
protected