4.1 upgrade breaks URL resolution on all my pages

Posted by Community Admin on 04-Aug-2018 20:12

4.1 upgrade breaks URL resolution on all my pages

All Replies

Posted by Community Admin on 20-Apr-2011 00:00

All my pages are giving me the following error.  How can I fix this?


Server Error in '/MyApplication' Application.

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.]
   Telerik.Sitefinity.Abstractions.VirtualPath.SitefinityPageResolver.AppendProperties(StringBuilder output, ObjectData ctrlData, Type ctrlType, CursorCollection placeHolders) +318
   Telerik.Sitefinity.Abstractions.VirtualPath.SitefinityPageResolver.BuildControls(PageData pageData, List`1 controlConatiners, CursorCollection placeHolders) +1604
   Telerik.Sitefinity.Abstractions.VirtualPath.SitefinityPageResolver.RenderPage(StringBuilder output, PageData pageData, RequestContext context, String virtualPath) +349
   Telerik.Sitefinity.Abstractions.VirtualPath.SitefinityPageResolver.Open(PathDefinition definition, String virtualPath) +253
   Telerik.Sitefinity.Abstractions.VirtualPath.VirtualPathManager.OpenFile(String virtualPath) +230
   System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath) +255
   System.Web.UI.TemplateParser.Parse() +11197050
   System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType() +135
   System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider) +189
   System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders() +265
   System.Web.Compilation.BuildProvidersCompiler.PerformBuild() +46
   System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +580
   System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +619
   System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +203
   System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) +189
   System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) +56
   Telerik.Sitefinity.Web.PageRouteHandler.GetHttpHandler(RequestContext requestContext) +844
   System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +11367992
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +266


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225

Posted by Community Admin on 20-Apr-2011 00:00

Do you have custom widgets or layout controls?

Posted by Community Admin on 20-Apr-2011 00:00

yes to both

Posted by Community Admin on 20-Apr-2011 00:00

That's the problem I believe

I have a similar issue...they told me to execute this code

string LayoutControlType = typeof(InfoPod).FullName;
       string LayoutPropName = "Layout";
  
       var upg =
           PageManager.GetManager().GetProperties()
           .Where(prop =>
               prop.Name == LayoutPropName
               && prop.Control.ObjectType == LayoutControlType
               && prop.Value == ""
               )
           .ToArray();
  
       foreach (var layoutProperty in upg)
       
           layoutProperty.Value = "~/OCFP/OCFP.Layouts.Views.InfoPod.ascx";
       
  
  
       LayoutControlType = typeof(Award).FullName;
       LayoutPropName = "Layout";
  
       upg =
           PageManager.GetManager().GetProperties()
           .Where(prop =>
               prop.Name == LayoutPropName
               && prop.Control.ObjectType == LayoutControlType
               && prop.Value == ""
               )
           .ToArray();
  
       foreach (var layoutProperty in upg)
       
           layoutProperty.Value = "~/OCFP/OCFP.Layouts.Views.Award.ascx";
       


So it's changing the layout templates in the database from
OCFP.Layouts.Views.InfoPod.ascx
to
~/OCFP/OCFP.Layouts.Views.Award.ascx

Which follows the new virtual path provider model they're using here
http://www.sitefinity.com/blogs/slavoingilizov/posts/11-04-18/taking_advantage_of_the_virtual_path_provider_in_sitefinity_4_1.aspx

So when I get to my laptop Im going to run this for every custom layout name I have...I THINK THINK this just has to be done for layout controls, not widgets?

(so I think you need the Global.asax code on top of this)

WARNING: Backup your database first, and use your layout strings, not mine above :)

Posted by Community Admin on 21-Apr-2011 00:00

Steve, thank you so much for your reply.  My original error was something slightly different but after I resolved that, I immediately ran into the error you've graciously outlined for me.  

Have you been able to get your layouts working using what they've told you to do?  I added the virtual path configuration entry, changed all the layout property values to the new virtual path format, but now I just get " System.IO.FileNotFoundException: ~/my_assembly/my_assembly.Resources.ControlTemplates.Layouts.Main.ThreeColumn.ascx"  instead of the old "Invalid Layout Template".  


What's odd is that the layouts work fine in design mode and when I preview the page.  The problem arises on the live page.  

Posted by Community Admin on 21-Apr-2011 00:00

Wierd that you sent this just now...Im literally JUST trying to implement this this minute

I had the same issue...preview was fine, live was borked...thats why I figured we have the same problem.

This code needs an update through

string LayoutControlType = typeof(InfoPod).FullName;
string LayoutPropName = "Layout";
 
var upg =
    PageManager.GetManager().GetProperties()
    .Where(prop =>
        prop.Name == LayoutPropName
        && prop.Control.ObjectType == LayoutControlType
        && prop.Value == ""
        )
    .ToArray();
 
foreach (var layoutProperty in upg)
    layoutProperty.Value = "~/OCFP/OCFP.Layouts.Views.InfoPod.ascx";
 
PageManager.GetManager().SaveChanges();
 

He left out the .SaveChanges() so the DB wasn't persisting anything

So for me the code now has me looking at live pages, but it's still a bit borked  Im going to restore my DB and try again, but it seems to have either duplicated the layouts...or something strange happened becasue Im definatly not looking normal.

Posted by Community Admin on 21-Apr-2011 00:00

So your global asax looks like this?

protected void Application_Start(object sender, EventArgs e)
    Telerik.Sitefinity.Abstractions.Bootstrapper.Initializing += new EventHandler<Telerik.Sitefinity.Data.ExecutingEventArgs>(Bootstrapper_Initializing);
 
protected void Bootstrapper_Initializing(object sender, Telerik.Sitefinity.Data.ExecutingEventArgs args)
    if (args.CommandName == "RegisterRoutes")
        var virtualPathConfig = Config.Get<VirtualPathSettingsConfig>();
        var jobsModuleVirtualPathConfig = new VirtualPathElement(virtualPathConfig.VirtualPaths)
            VirtualPath = "~/my_asembly/*",
            ResolverName = "EmbeddedResourceResolver",
            ResourceLocation = "my_asembly"
        ;
        virtualPathConfig.VirtualPaths.Add(jobsModuleVirtualPathConfig);
    

Posted by Community Admin on 21-Apr-2011 00:00

ALSO! 

If your layout controls have IDs specified you're supposed to remove those (the runat="server" ones) or impliment the (stupid) NamingContainer

Posted by Community Admin on 21-Apr-2011 00:00

So just a heads up too (after restoring my DB)

It seems that removing the IDs was the problem, had nothing to do with the code the agent sent me....so Im not even going to run that yet on this freshly restored db


**EDIT** scratch that, still needed to be run, but still getting yellow screens of death allover the place...4.1 is such a pain in the ass

Posted by Community Admin on 21-Apr-2011 00:00

- I did catch that the manager needed to call SaveChanges(), sorry I should have said something
- my global.asax does look just like that

still, my errors alternate between the "FileNotFound" and "Invalid layout template" screens.  

"If your layout controls have IDs specified you're supposed to remove those (the runat="server" ones) or impliment the (stupid) NamingContainer"  -- I don't quite understand what you mean here, do you mean to remove the IDs?

I have a day to make 4.1 work before we revert back to 4.0 sp1... thanks so much for all your input thus far, and I'd hugely appreciate it if you could keep this thread updated if you make any progress with this nastiness.  



Posted by Community Admin on 21-Apr-2011 00:00

Yeah I know all the documentation shows each Div in the layout needs an ID...but I am being told to remove the IDs...and really once I did the page RENDERED, but stuff was allover the place and edit mode shows me none of that content.  So it's got to be that SF wants to render content in Placeholder (layout) X, but that name doesn't exist anymore perhaps because the ID is gone.  So I have no doubt that starting from scratch this would all just work.  But I've spent the last few weeks creating the structure, entering content, and fixing URLs, and damned if I want to go back and do that AGAIN.

So screw it, back to the support tickets, maybe Radoslav has an idea...I don't want to have to go back through every page to fix everything...

This thread is closed