using System.Web.Mvc;
namespace PMS.WebApp.Models
{
public class CheckLoginAttribute:ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
base.OnActionExecuting(filterContext);
if (filterContext.HttpContext.Session == null || filterContext.HttpContext.Session["user"] == null)
{
filterContext.HttpContext.Response.Redirect("/User/Login");
}
}
}
}
using System.Web.Mvc;
using PMS.IBLL;
using PMS.WebApp.Models;
namespace PMS.WebApp.Controllers
{
public class UserController : Controller
{
//
// GET: /User/
//private IUserService _userService;
//private IUserService UserService
//{
// get { return _userService ?? (_userService = new UserService()); }
// set { _userService = value; }
//}
private IUserService UserService { get; set; }
[CheckLogin]
public ActionResult Index()
{
return Content("OK");
}
}
}
using System.Web.Mvc;
namespace PMS.WebApp.Controllers
{
public class FilterController : Controller
{
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
base.OnActionExecuting(filterContext);
if (Session["user"] == null)
{
//filterContext.HttpContext.Response.Redirect("/User/Login");
filterContext.Result = Redirect("/User/Login");
}
}
}
}
using System.Web.Mvc;
using PMS.IBLL;
namespace PMS.WebApp.Controllers
{
public class UserController : FilterController//Controller
{
//
// GET: /User/
//private IUserService _userService;
//private IUserService UserService
//{
// get { return _userService ?? (_userService = new UserService()); }
// set { _userService = value; }
//}
private IUserService UserService { get; set; }
//[CheckLogin]
public ActionResult Index()
{
return Content("OK");
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2026 源码网商城 (www.ymwmall.com) 版权所有