提供空引用异常的Kentico页面类型提供程序

时间:2019-09-25 14:49:25

标签: c# asp.net-mvc kentico kentico-mvc

我们有带有MVC的Kentico 11.0.26

对于网站范围的页脚,我们有一个页脚页面类型。此页面类型的数据库字段是通过MVC应用程序中的基本控制器加载的。不知道为什么我在这一行(下面的堆栈跟踪中的第68行)在Kentico生成的代码中得到空引用异常

    /// <summary>
    /// Returns a published page of type Footer that matches the specified criteria.
    /// </summary>
    /// <param name="nodeAliasPath">The alias path to the content tree node that represents the page.</param>
    /// <param name="siteName">The name of the site where the page belongs.</param>
    /// <param name="cultureName">The name of the language, e.g. en-US, that determines which localized version should be retrieved.</param>
    public static DocumentQuery<Footer> GetFooter(string nodeAliasPath, string cultureName, string siteName)
    {
        return GetFooters().OnSite(siteName).Culture(cultureName).Path(nodeAliasPath);
    }

GetFooter中的BaseController的调用如下所示(下面堆栈跟踪的第47行):

Footer footer = FooterProvider.GetFooter("/Footer", "en-us", SiteContext.CurrentSiteName)
                .Columns("DocumentName", "PhysicalHeading", "PhysicalAddress", "MailingHeading", "MailingAddress", "PhoneHeading", "PhoneNumbers", "LogoImage", "Link1Text", "Link1URL", "FacebookURL", "TwitterURL", "InstagramURL", "YouTubeURL", "LinkedInURL");

这是完整的堆栈跟踪:

“ /”应用程序中的服务器错误。


对象引用未设置为对象的实例。 说明:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息。

异常详细信息:System.NullReferenceException:对象引用未设置为对象的实例。

源错误: 当前Web请求的执行期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来标识有关异常的来源和位置的信息。

堆栈跟踪:

[NullReferenceException:对象引用未设置为对象的实例。]    CMS.DocumentEngine.DocumentQueryBase 2.OnSite(SiteInfoIdentifier siteIdentifier, Boolean includeGlobal) +13 CMS.DocumentEngine.Types.LIT.FooterProvider.GetFooter(String nodeAliasPath, String cultureName, String siteName) in C:\MyWebsite\PageTypes\FooterProvider.cs:68 MyWebsite.Controllers.BaseController.GetFooterModel() in C:\MyWebsite\Controllers\BaseController.cs:47 MyWebsite.Controllers.BaseController.OnActionExecuted(ActionExecutedContext filterContext) in C:\MyWebsite\Controllers\BaseController.cs:36 System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +378 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +41 System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +37 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +188 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38 System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +32 System.Web.Mvc.Async.WrappedAsyncVoid 1.CallEndDelegate(IAsyncResult asyncResult)+73    System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)+52    System.Web.Mvc.Async.WrappedAsyncVoid 1.CallEndDelegate(IAsyncResult asyncResult) +39 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38 System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +46 System.Web.Mvc.Async.WrappedAsyncVoid 1.CallEndDelegate(IAsyncResult asyncResult)+73    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)+38    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+431    System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep步骤)+75    System.Web.HttpApplication.ExecuteStep(IExecutionStep步骤,布尔值并已完成同步)+158


版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.8.3928.0

0 个答案:

没有答案