在控制器中:
protected override void Initialize(RequestContext requestContext)
{
if (db == null) { db = new myRepository(); }
if (currentCalendar == null)
{
currentCalendar =
db.FindCalendarInfoByUrl(
requestContext.RouteData.Values["calurl"].ToString());
// if not found ... show Unavailable Content View
if (currentCalendar == null)
RedirectToAction("ContentNotAvailable");
// to show in the MasterPage
Session["GoogleId"] = currentCalendar.GoogleAnalyticsId;
}
base.Initialize(requestContext);
}
Session
变量尚未在请求的此时定义,我无法使用
ViewData
或者因为它总是空的。。。
如何使用传递这两个变量
GoogleId
和
CalendarUrl
致
MasterPage
?
我想我可以用
Cache
,但有太多,我还没有进入缓存:
alt text http://www.balexandre.com/temp/2010-11-17_2328.png
我最好的选择是什么
为了达到这个目的?