Creating a layout file - Error when viewing under project
I am trying to create a layout file as outlined as in this document docs.sitefinity.com/feather-create-layout-files
After following steps 1-6 have the new template appear in the templates list for the project
But when I click on the template page I get the following error ... is there something else to be done ?
(I have Feather enabled for the project)
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
ASP._MVC_Views_Layouts_MyNewTemplate_cshtml.Execute() in D:\Sitefinity\Promo40\obj\CodeGen\MVC\MVC\Views\Layouts\MyNewTemplate.cshtml:7
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +252
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +142
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +106
Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Layouts.LayoutRenderer.RenderViewToString(ControllerContext context, String viewPath, Boolean placeholdersOnly) +486
Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Layouts.LayoutRenderer.GetLayoutTemplate(String templateName, Boolean placeholdersOnly) +59
Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Layouts.LayoutVirtualFileResolver.Open(PathDefinition definition, String virtualPath) +160
Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Layouts.MvcMasterPage.LayoutOutput(String path) +219
Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Layouts.MvcMasterPage.ApplyToPage(Page page) +214
Telerik.Sitefinity.Frontend.Mvc.Infrastructure.PageInitializer.PreInitHandler(Object sender, EventArgs e) +180
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Page.OnPreInit(EventArgs e) +120
System.Web.UI.Page.PerformPreInit() +31
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1147
Hi,
It is not entirely clear to me when exactly you are getting this error, when opening in Visual Studio or selecting it whilst creating a new page in the Sitefinity backend ?
cfr. my sample: http://screencast.com/t/Va71d0D4Q
I did notice that you have a folder "MVC" under "MVC".
Could you maybe upload a screenshot of where you are getting this error ?
Regards,
Dimitri Cools
Telerik
my bad .... once the layout was created in the MVC project and re-building the project - I was going to the newly added layout via Design/Page templates - where it was listed but I would get a run-time error when I clicked the "feather layout template" (possibly because it was a template in the VS project)
However if I create a page and then select the new template it works