【发布时间】:2011-05-15 16:43:32
【问题描述】:
这是不好的做法吗?
using System.Web.Mvc;
namespace WebInventaris.Utils.Session
{
public static class SessionControllerExtensions
{
public static void SetSessionVar<T>(this Controller controller, string field, T value)
{
controller.Session[field] = value;
}
public static T GetSessionVar<T>(this Controller controller, string field)
{
return (T) controller.Session[field];
}
}
}
我正在尝试将 Session 与我的控制器分开,但我对这些方法的感觉并不好。
【问题讨论】:
标签: extension-methods session-state asp.net-mvc-3