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
Hello, so im wonderinmg if somone could help me to read a error message.
I know its a null referenceException but i dont know where it comes from.
What i can read from it its about some Template? or am i reading it wrong?
An unhandled exception occurred
System.NullReferenceException: Object reference not set to an instance of an object.
at Umbraco.Web.PublishedContentExtensions.IsAllowedTemplate(IPublishedContent content, Int32 templateId)
at Umbraco.Web.Routing.ContentFinderByNiceUrlAndTemplate.TryFindContent(PublishedContentRequest docRequest)
at Umbraco.Web.Routing.ContentFinderByNotFoundHandlers.HandlePageNotFound(PublishedContentRequest docRequest)
at Umbraco.Web.Routing.ContentFinderByNotFoundHandlers.TryFindContent(PublishedContentRequest docRequest)
at Umbraco.Web.Routing.PublishedContentRequestEngine.<FindPublishedContent>b__17_0(IContentFinder finder)
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
at Umbraco.Web.UmbracoModule.ProcessRequest(HttpContextBase httpContext)
at Umbraco.Web.UmbracoModule.<Init>b__12_3(Object sender, EventArgs e)
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
The key to understanding this error message is to know which url triggers it, eg is it on all requests or are you finding it for a particular page, or just seeing it in the logs from time to time?
Essentially if the Url that triggers the problem is
Then what happens when a request comes into Umbraco, is Umbraco needs to find the published content item that matches to the incoming Url. A series of 'finding rules' - called ContentFinders are executed one after another until a matching content item is found.
In your tracelog error, you can see Umbraco gets as far through this list as
and the error message is triggered when checking whether the template 'is allowed' for a content item.
This ContentFinder is one of the very last rules to execute before returning a 404 for the request, and is performing a check for an obscure Umbraco convention called 'altTemplate' (which enables you to force a particular page to load with a different template than the one it is published with by adding ?altTemplate to the querystring - and there is a shortcut for this convention, to avoid using the querystring to just have the name of the template as the last segment).
So in our example of /about-us/contactus
You'd expect to see in the Umbraco Content tree, an 'about-us' node and underneath this a 'contactus' node... however if there is no 'contactus' node AND there is a template called 'contactus' - this instruction will load the 'about-us' page and force it to use the 'contactus' template.
You can turn this convention 'off' by updating the setting disabledAlternativeTemplates in /config/umbracosettings.config
Now back to your error... a while back it was pointed out that this default convention could be used by a hacker to show the contents of a template that they shouldn't have permissions to access - and so a check to make sure the template 'IsAllowed' was added.... and this is where your error is being triggered...
if you have a look at the Umbraco Source code for ContentFinderByNiceUrlAndTemplate...
You can hopefully see,that for the incoming request the template name is taken from the last segment, and used to find a matching template on disk, if one exists, then an Umbraco node is sought at the url, without the template segment, and then it's checked whether the template is allowed for that content node... however no null check is made for this node without the template segment, so if one isn't matched... the error message you are seeing is thrown!
so in our /about-us/contactus example, it would mean there IS a template called 'contactus' and Umbraco removes contactus from the Url and looks for content at /about-us... and there isn't any! so the check for IsAllowedTemplate triggers the error.
So in your circumstance to make the errors go away, if you don't use or plan to use the alternative templates convention you can disable the convention n the umbracosettings.config file... if you do need the convention then try to make sure your templates are named with 'possible' matches to content, eg called the template: ContactUsPage, and not ContactUs... to prevent accidental occurences.... and I guess we should try to put the Null check into future versions of Umbraco! (I have checked and it's fixed in Umbraco V8!)
Do you have an ETA for the null check in V7?
There is a PR here Jonas:
if that helps, you could take the code from there now, and then remove the existing Umbraco implementation of ContentFinderByNiceUrlAndTemplate from the stack of registered ContentFinders and add your own
MySuperContentFinderByNiceUrlAndTemplate in the queue in it's place.
if that helps!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted