Quick/simple fix for the stale variable

The umbracoContext variable can hold a null reference to UmbracoContext.Current. 

If a request containing a file extension is passed through an UmbracoVirtualNodeRouteHandler, the UmbracoContext will be null, because a context is never created for urls containing extensions due to 5397f2c53a/src/Umbraco.Core/UriExtensions.cs (L143)

A call can be made to EnsureContext in the overridden FindContent method, but the fresh context would never get picked up, instead the variable always contains a null reference, and an exception is then thrown on line 23
This commit is contained in:
Tom Pipe
2017-04-24 13:23:12 +01:00
committed by GitHub
parent f2c7c1e2c6
commit 67e3ec2ae0

View File

@@ -15,11 +15,11 @@ namespace Umbraco.Web.Mvc
{
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
var umbracoContext = UmbracoContext.Current;
var found = FindContent(requestContext, umbracoContext);
var found = FindContent(requestContext, UmbracoContext.Current);
if (found == null) return new NotFoundHandler();
var umbracoContext = UmbracoContext.Current;
umbracoContext.PublishedContentRequest = new PublishedContentRequest(
umbracoContext.CleanedUmbracoUrl, umbracoContext.RoutingContext,
UmbracoConfig.For.UmbracoSettings().WebRouting, s => Roles.Provider.GetRolesForUser(s))