提交 9158b0de 编写于 作者: W weichunjie

增加拦截器

上级 1592bd3f
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Blog.Web.App_Start
{
public class AuthorizeFilter : AuthorizeAttribute
{
public override void OnAuthorization(AuthorizationContext filterContext)
{
if (filterContext.ActionDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true) || filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true))
{
return;
}
if (filterContext.HttpContext.Session["user"] == null)
{
filterContext.HttpContext.Response.Redirect("/gl/");
}
}
}
}
\ No newline at end of file
......@@ -177,6 +177,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="App_Start\AuthorizeFilter.cs" />
<Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\ExUrlProvider.cs" />
<Compile Include="App_Start\FilterConfig.cs" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册