【发布时间】:2013-05-22 17:04:15
【问题描述】:
在标准的 asp.NET 中是否有 MVC.NET 的 OnActionExecuting 的等价物? ?
我认为它会是Page_Load,因为每次执行操作(或加载页面)时都会调用OnActionExecuting。但是当我尝试改用 Page_Load 时,我遇到了继承问题。
由于使我的解决方案与Page_Load 一起工作非常困难,我想我可能没有最好的......解决方案。
关于它们是否相等或足够接近的任何想法?
背景:
我正在将 MVC3 应用程序的一部分转换为标准 .NET 以包装在 SharePoint Web 部件中。
这是我要翻译的 MVC 代码,您可以看到我正在翻译的用户安全位:
protected override void OnActionExecuting(ActionExecutingContext filterContext) {
if (!SiteCacheProvider.ItemCached(enmCacheKey.SiteSetting)) {
if (filterContext.IsImplementedGeneralPrincipal()) {
IUserProfile userProfile = ((IGeneralPrincipal)filterContext.HttpContext.User).UserProfile;
SiteCacheProvider.ChangeSiteSetting(userProfile.SiteID);
}
}
base.OnActionExecuting(filterContext);
}
【问题讨论】:
-
你有到目前为止的代码示例吗?
-
@RaimondKuipers 我的 asp.NET 代码还是我正在转换的 MVC 代码?
-
两者都会有帮助
-
@MyName 看看我的回答。
-
@RaimondKuipers :这就是很多代码
标签: c# asp.net asp.net-mvc-3 webforms web-parts