日期:2014-05-17 浏览次数:20944 次
using System;
using System.Web;
namespace Test
{
public class AbcAttribute : Attribute
{
public AbcAttribute()
{
HttpContext.Current.Session["abc"] = "vvv";
}
}
}
namespace Test.Controllers
{
public class HomeController : Controller
{
[Abc()]
public ActionResult Index()
{
return View();
}
}
}
class SessionAttribute : System.Web.Mvc.ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
filterContext.HttpContext.Session["abc"] = "vvv";
base.OnActionExecuting(filterContext);
}
}