forked from yuezhongxin/MessageManager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSessionCheck.cs
More file actions
38 lines (33 loc) · 988 Bytes
/
Copy pathSessionCheck.cs
File metadata and controls
38 lines (33 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* author:xishuai
* address:https://www.github.com/yuezhongxin/MessageManager
**/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;
namespace MessageManager.Web.Controllers
{
/// <summary>
/// Session验证过期验证特性
/// </summary>
public class UserSessionCheck : System.Web.Mvc.ActionFilterAttribute
{
public UserSessionCheck()
{
}
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
HttpContextBase ctx = filterContext.HttpContext;
if (ctx.Session["userName"] == null)
{
filterContext.Result = new EmptyResult();
ctx.Response.Write("<script type='text/javascript'>window.location.href ='/index/index';</script> ");
}
base.OnActionExecuting(filterContext);
}
}
}