Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I have problem when creating new pages. All new pages gets the error I have pasted below.
The error occurs when accessing the Model.
@Model.Name
The template inherits from UmbracoViewPage.
I have a number of pages that uses the same template and they work fine. Only new pages gets this error.
ModelsMode is "Dll".
I have tried the "Rebuild" and "Reload" in "Published status".
Example : https://eftersandning.se/ta-bort/
Umbraco version : 8.1
Does anyone have any ideas?
[NullReferenceException: Object reference not set to an instance of an object.] ASP.PageViewskampanjmastercshtml.Execute() in C:\inetpub\wwwroot\tackeftersandning\Views\kampanjmaster.cshtml:40 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +251 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +147 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +121 System.Web.WebPages.<>cDisplayClass400.0(TextWriter writer) +308 System.Web.WebPages.WebPageBase.Write(HelperResult result) +107 System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action1 body) +88 System.Web.WebPages.WebPageBase.PopContext() +309 Umbraco.Web.Mvc.ProfilingView.Render(ViewContext viewContext, TextWriter writer) +179 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +377 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +90 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +793 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +793 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +793 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList1 filters, ActionResult actionResult) +81 System.Web.Mvc.Async.<>cDisplayClass31.1(IAsyncResult asyncResult) +188 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38 System.Web.Mvc.<>c.
1 body) +88 System.Web.WebPages.WebPageBase.PopContext() +309 Umbraco.Web.Mvc.ProfilingView.Render(ViewContext viewContext, TextWriter writer) +179 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +377 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +793 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +793 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList
Regards / Aki
When looking at your URL you're accessing "@home.Name", perhaps you forgot to do something like:
var home = Model;
Have you tried just using @Model.Name?
Thanks for the feedback.
I actually had @Model.Name there first. Same error with it.
I changed it to:
var home = (Kampanjsida)Model.Root(); <title>@home.Name</title>
Odd, it should work by default.
Perhaps there was something wrong in your @inherits ?
Good that it works for now ;-)
I still get the same error.
Other pages with exact same templates work:
Example : https://eftersandning.se/att-vilja-leva-sjalvforsorjande-allt-mer-populart/
New pages dont work. Created a new test page.
https://eftersandning.se/ta-bort/
If old pages work, and new ones don't, do the old pages, when republished, stop working as well? It could be that the old ones are cached.
Can you show a sample of the code ? Where you declare the using / inherits ? I think you have an error somewhere..
I'd rather not try to republish and risk that the page will break. There are ongoing campaigns in social media with links to those pages. :)
Yes, here is the HEAD. Stripped out some unimportant stuff.
@using Umbraco.Core.PropertyEditors @inherits UmbracoViewPage<Kampanjsida> @{ Layout = null; var home = (Kampanjsida)Model.Root(); var thumbnailImage = (Image)Model.Value("thumbnailImage"); var topLogotype = (Image)Model.Value("topLogotype"); var topLogotypeLink = (string)Model.Value("topLogotypeLink"); } <!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <title>@home.Name</title> <meta name="description" content=""> <meta name="author" content=""> <meta property=”og:title” content="@home.Name" /> <meta property=”og:url” content="@home.Url" /> <meta property=”og:type” content="article" /> <meta property=”og:description” content="@Model.SeoMetaDescription" /> <meta property=”og:image” content="@thumbnailImage.Url" /> @RenderSection("Header", required: false) </head>
I have setup the site locally and get the same behviour. I tried to unpublish a working page and the publish it again. And it works fine.
Hmm odd, the code looks fine. I've tried it on my own project and it works as expected..
The only thing I can imagine is that your "Kampanjsida" does not have a Name property.. But that would be a bit odd.
I'm inclined to think it has something to do with your ModelBuilder. Have you perhaps recently updated to 8.5?
But FIRST: I'd try to NOT do anything more on the live version, try to fix it locally first, so that you have some backup ;-)
Thanks for your input.
It's running on 8.1.
Very odd indeed. I have not touched it and the customer has been working with it for a couple of months. And then suddenly with a new page this happends.
I will try to reproduce locally.
Hi Aki
Maybe something happened to Models builder or Umbraco cache?
Did you try to restart an app?
Alex
This is now solved.
I have a field called "thumbnailIImage" in the document and that was not set as mandatory even though the template uses the field.
So the new pages were saved without that field set.
Thanks for all suggestions and feedback.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Model error in template
Hi,
I have problem when creating new pages. All new pages gets the error I have pasted below.
The error occurs when accessing the Model.
@Model.Name
The template inherits from UmbracoViewPage.
I have a number of pages that uses the same template and they work fine. Only new pages gets this error.
ModelsMode is "Dll".
I have tried the "Rebuild" and "Reload" in "Published status".
Example : https://eftersandning.se/ta-bort/
Umbraco version : 8.1
Does anyone have any ideas?
[NullReferenceException: Object reference not set to an instance of an object.] ASP.PageViewskampanjmastercshtml.Execute() in C:\inetpub\wwwroot\tackeftersandning\Views\kampanjmaster.cshtml:40 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +251 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +147 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +121 System.Web.WebPages.<>cDisplayClass400.0(TextWriter writer) +308 System.Web.WebPages.WebPageBase.Write(HelperResult result) +107 System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action
1 body) +88 System.Web.WebPages.WebPageBase.PopContext() +309 Umbraco.Web.Mvc.ProfilingView.Render(ViewContext viewContext, TextWriter writer) +179 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +377 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +90 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +793 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +793 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +793 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList
1 filters, ActionResult actionResult) +81 System.Web.Mvc.Async.<>cDisplayClass31.1(IAsyncResult asyncResult) +188 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38 System.Web.Mvc.<>c.Regards / Aki
When looking at your URL you're accessing "@home.Name", perhaps you forgot to do something like:
Have you tried just using @Model.Name?
Thanks for the feedback.
I actually had @Model.Name there first. Same error with it.
I changed it to:
Regards / Aki
Odd, it should work by default.
Perhaps there was something wrong in your @inherits ?
Good that it works for now ;-)
I still get the same error.
Other pages with exact same templates work:
Example : https://eftersandning.se/att-vilja-leva-sjalvforsorjande-allt-mer-populart/
New pages dont work. Created a new test page.
https://eftersandning.se/ta-bort/
If old pages work, and new ones don't, do the old pages, when republished, stop working as well? It could be that the old ones are cached.
Can you show a sample of the code ? Where you declare the using / inherits ? I think you have an error somewhere..
I'd rather not try to republish and risk that the page will break. There are ongoing campaigns in social media with links to those pages. :)
Yes, here is the HEAD. Stripped out some unimportant stuff.
I have setup the site locally and get the same behviour. I tried to unpublish a working page and the publish it again. And it works fine.
Hmm odd, the code looks fine. I've tried it on my own project and it works as expected..
The only thing I can imagine is that your "Kampanjsida" does not have a Name property.. But that would be a bit odd.
I'm inclined to think it has something to do with your ModelBuilder. Have you perhaps recently updated to 8.5?
But FIRST: I'd try to NOT do anything more on the live version, try to fix it locally first, so that you have some backup ;-)
Thanks for your input.
It's running on 8.1.
Very odd indeed. I have not touched it and the customer has been working with it for a couple of months. And then suddenly with a new page this happends.
I will try to reproduce locally.
Regards / Aki
Hi Aki
Maybe something happened to Models builder or Umbraco cache?
Did you try to restart an app?
Alex
Hi,
This is now solved.
I have a field called "thumbnailIImage" in the document and that was not set as mandatory even though the template uses the field.
So the new pages were saved without that field set.
Thanks for all suggestions and feedback.
Regards / Aki
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.