1
Route "FileUploaderHandler" is not registered.
Problem reported by SHARPDEV SPRL - 1/12/2016 at 3:00 PM
Resolved
Hi,
I use Composite C1 CMS and would like to integrate the FileUltimate Control in a template. However, I get this error:
 

Route "FileUploaderHandler" is not registered. 
  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.Exception: Route "FileUploaderHandler" is not registered.

Source Error: 



Line 10:     <form id="form1" runat="server">
Line 11:     <div>
Line 12:         <GleamTech:FileManager ID="fileManager" runat="server" />
Line 13:     </div>
Line 14:     </form>
  


[Exception: Route "FileUploaderHandler" is not registered.]
   GleamTech.Web.HttpHandlerRouteHandler`1.GetUrl(String pathInfo, Boolean usesSession, String routeName, NameValueCollection queryParameters) +449
   GleamTech.FileUltimate.FileUploader..ctor() +133
   GleamTech.FileUltimate.FileManager..ctor(FileUltimateConfiguration configuration) +145
   ASP.renderers_test_aspx.__BuildControlfileManager() in c:\wwwroot\2014my.epca.eu\Renderers\test.aspx:12
   ASP.renderers_test_aspx.__BuildControlform1() in c:\wwwroot\2014my.epca.eu\Renderers\test.aspx:10
   ASP.renderers_test_aspx.__BuildControlTree(renderers_test_aspx __ctrl) in c:\wwwroot\2014my.epca.eu\Renderers\test.aspx:1
   ASP.renderers_test_aspx.FrameworkInitialize() in c:\wwwroot\2014my.epca.eu\Renderers\test.aspx.cs:912307
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +68
   System.Web.UI.Page.ProcessRequest() +119
   System.Web.UI.Page.ProcessRequest(HttpContext context) +99
   ASP.renderers_test_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\279d1423\74d102e2\App_Web_test.aspx.d5b9010.crvg9ft8.0.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +913
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165

  

The strangest thing is that I have only the error on my production server and not on my development machine.
 
Do you have an idea of the problem?
 
Thank you in advance for your answer.
 
Kind Regards.

14 Replies

Reply to Thread
0
Cem Alacayir Replied
Employee Post
Hi,
This error can happen if the RouteTable is cleared at some point. When your web application starts, FileUltimate registers its own routes so it seems the CMS is removing these entries so FileUltimate can not find them anymore.
 
Luckily, we already have a backup method for cases like this:
 
FileUltimateConfiguration.RestoreRoutes();
Call this method inside Application_Start of your Global.asax. Or if this is not available with your CMS, you can call it in your template. This usually needs to be called once per application and not per each view so you may check with a static variable if you already called it.
0
SHARPDEV SPRL Replied
Hi,
 
Thank you for your rapid answer!
 
Unfortunately, I now have another problem. It seems that the Composite C1 CMS uses its own routing class derived from the standard routing. When I execute the function FileUltimateConfiguration.RestoreRoutes() (in Application_Start of Global.asax or in my Template), I receive this error message:
 
Unable to cast object of type 'Composite.Core.Routing.Pages.C1PageRoute' to type 'System.Web.Routing.Route'. 
Here is the code of my Global.asax Application_Start:
 
 void Application_Start(object sender, EventArgs e)
    {
        ApplicationLevelEventHandlers.LogRequestDetails = false;
        ApplicationLevelEventHandlers.LogApplicationLevelErrors = false;

        ApplicationLevelEventHandlers.Application_Start(sender, e);

        RegisterRoutes(RouteTable.Routes);

         #region Gleamtech License
        GleamTech.FileUltimate.FileUltimateConfiguration.Current.LicenseKey = "xxxxxxxxxxxx";
        #endregion
    }

    public static void RegisterRoutes(RouteCollection routes)
    {
        Routes.RegisterPageRoute(routes);

        // If necessary, add the standard MVC route "{controller}/{action}/{id}" after registering the C1 page route
        GleamTech.FileUltimate.FileUltimateConfiguration.RestoreRoutes();

        Routes.Register404Route(routes);
    }
In the code Routes.RegisterPageRoute(routes) is a Composite C1 object function.
Is it possible to add the FileUltimate routes manually?
 
Thank you in advance for your answer.
 
Kind Regards.
 
 
0
Cem Alacayir Replied
Employee Post
Ok, you found a bug in registering the routes, please download this new build of GleamTech.Core.dll (link removed)
 
This will fix this issue:
 
- Fixed: Routes were not registered/restored correctly if RouteTables contained instances of custom types derived from  the default Route class.
Actually, you may not even need to call FileUltimateConfiguration.RestoreRoutes() at all because this problem may also have effected automatic registration too. After you update GleamTech.Core.dll see if it works out of the box without calling that method, only if you get a similar error (Route "FileUploaderHandler" is not registered) then call it. However this time the call will not fail with "Unable to cast object of type...".
 
0
SHARPDEV SPRL Replied
Hi,
 
I'am sorry but the patch don't resolve my problem. I still have the error "Route "FileUploaderHandler" is not registered".
When I call the function "FileUltimateConfiguration.RestoreRoutes()" in my Global.asax, I have no error but still the same error "Route "FileUploaderHandler" is not registered" when calling my template with the control.
 
Thank you in advance for your answer.
 
Kind Regards.
 
0
Cem Alacayir Replied
Employee Post
Does it work when you call it in your template instead of Global.asax?
0
SHARPDEV SPRL Replied
No. Same problem. :-(
0
SHARPDEV SPRL Replied
As I have said in my first post, I have no problem on my development machine. On my development machine I have 17 routes. The same page on my production server: 12 routes.
0
Cem Alacayir Replied
Employee Post
For testing, I downloaded Composite C1 5.0 and setup an empty site (Venus Starter Site).
 
  1. I created Composite C1\Website\Frontend\Controls\FileManager.ascx and inserted below code in this file:
    <%@ Control Language="C#" %>
    <%@ Register TagPrefix="GleamTech" Assembly="GleamTech.FileUltimate" Namespace="GleamTech.FileUltimate" %> 
      
    <GleamTech:FileManager ID="fileManager" runat="server" 
                               Width="800"
                               Height="600"
                               Resizable="True">
                               
        <GleamTech:FileManagerRootFolder Name="1. Root Folder" Location="~/"> 
            <GleamTech:FileManagerAccessControl Path="\" AllowedPermissions="Full"/> 
        </GleamTech:FileManagerRootFolder> 
                                         
    </GleamTech:FileManager>            
     
  2. Then I copied all 5 DLLs of FileUltimate to Composite C1\Website\Bin folder.
  3. Finally in Composite C1  UI, I inserted LoadUserControl in the main page (as described here) with path ~/Frontend/Controls/FileManager.ascx and just clicked Preview tab and voila! FileManager was displayed without any errors. Note that I did not even use the patch above, I just used DLLs from the 5.0.4 package.
So, are you using an older version of Composite C1 or are you doing something different than the above steps I followed?
 
Also I did this test on IIS and not on Visual Studio/IIS Express.
0
SHARPDEV SPRL Replied
Dear Cem,
 
First of all, thank you for your efforts. I really appreciate this!
 
My version of Composite C1 is different. Mine is 4.2 Update 1.
 
Rem : My WebSite is in WebSite mode not in WebApplication mode. 
 
My development machine is a Windows 10 with Visual Studio 2015.
My production server is a Windows Server 2012 R2
 
Here are the steps I followed:
 
1. I copied all 5 Gleamtech dlls in bin folder on Composite.
2. I added the line code for license in Application_Start of my Global.asax:
 
GleamTech.FileUltimate.FileUltimateConfiguration.Current.LicenseKey = "XXXXX"
3. For testing purpose, I created a webform page test.aspx in the folder /WebSite/Renderers/ with this code behind:
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GleamTech.FileUltimate;
using System.Web.Routing;

public partial class Renderers_test : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        GleamTech.FileUltimate.FileUltimateConfiguration.RestoreRoutes();

        Response.Write(RouteTable.Routes.Count + "<br/>");

        foreach (var _RouteItem in RouteTable.Routes)
        {
            try
            {
                var _r = (Route)_RouteItem;

                Response.Write(_r.RouteHandler + " | " + _r.Url + " | " + _r.Constraints + "</br>");

            }
            catch { }

        }
    }
}
Result of execution on my development machine:
 
1. With the original GleamTech.Core.dll, I received this error : 
 
Unable to cast object of type 'Composite.Core.Routing.Pages.C1PageRoute' to type 'System.Web.Routing.Route'. 
2. With the new version of the dll, no error. Here is the result:
 
17
GleamTech.Web.HttpHandlerRouteHandler`1[GleamTech.Web.ResourceHandler] | resource.ashx/{*pathInfo} | System.Web.Routing.RouteValueDictionary
GleamTech.Web.HttpHandlerRouteHandler`1[GleamTech.DocumentUltimate.Web.DocumentViewerHandler] | documentviewer.ashx/{*pathInfo} | System.Web.Routing.RouteValueDictionary
GleamTech.Web.HttpHandlerRouteHandler`1[GleamTech.FileUltimate.FileManagerHandler] | filemanager.ashx/{*pathInfo} | System.Web.Routing.RouteValueDictionary
GleamTech.Web.HttpHandlerRouteHandler`1[GleamTech.FileUltimate.FileUploaderHandler] | fileuploader.ashx/{*pathInfo} | System.Web.Routing.RouteValueDictionary
GleamTech.Web.HttpHandlerRouteHandler`1[GleamTech.ImageUltimate.Web.ImageHandler] | image.ashx/{*pathInfo} | System.Web.Routing.RouteValueDictionary
System.Web.Routing.StopRoutingHandler | Composite/{*pathInfo} | System.Web.Routing.RouteValueDictionary
System.Web.Routing.StopRoutingHandler | {resource}.axd/{*pathInfo} | System.Web.Routing.RouteValueDictionary
Composite.Core.WebClient.FunctionBoxRouteHandler | Renderers/FunctionBo{x} | 
Composite.Core.WebClient.TemplatePreviewRouteHandler | Renderers/TemplatePreviewImag{e} | 
System.Web.Routing.StopRoutingHandler | sitemap.xml | System.Web.Routing.RouteValueDictionary
System.Web.Routing.StopRoutingHandler | {language}/sitemap.xml | System.Web.Routing.RouteValueDictionary
System.Web.Routing.StopRoutingHandler | {language}/{urlTitle}/sitemap.xml | System.Web.Routing.RouteValueDictionary
System.Web.Routing.StopRoutingHandler | Renderers/{*pathInfo} | System.Web.Routing.RouteValueDictionary
System.Web.Routing.StopRoutingHandler | {*all_css_aspx} | System.Web.Routing.RouteValueDictionary
System.Web.Routing.StopRoutingHandler | {*all_js_aspx} | System.Web.Routing.RouteValueDictionary
Composite.Core.Routing.PageNotFoundRouteHandler | {*url} | 
On the production server:
 
1. I copied the Gleamtech dlls in the bin folder of Composite
2. I copied the test.aspx in /WebSite/Renderers/
3. Add the line code for license in Global.asax
4. With the original GleamTech.Core.dll --> same error as development environment 
5. With the new version of dll, Here is the result:
 
12
System.Web.Routing.StopRoutingHandler | Composite/{*pathInfo} | System.Web.Routing.RouteValueDictionary
System.Web.Routing.StopRoutingHandler | {resource}.axd/{*pathInfo} | System.Web.Routing.RouteValueDictionary
Composite.Core.WebClient.FunctionBoxRouteHandler | Renderers/FunctionBo{x} | 
Composite.Core.WebClient.TemplatePreviewRouteHandler | Renderers/TemplatePreviewImag{e} | 
System.Web.Routing.StopRoutingHandler | sitemap.xml | System.Web.Routing.RouteValueDictionary
System.Web.Routing.StopRoutingHandler | {language}/sitemap.xml | System.Web.Routing.RouteValueDictionary
System.Web.Routing.StopRoutingHandler | {language}/{urlTitle}/sitemap.xml | System.Web.Routing.RouteValueDictionary
System.Web.Routing.StopRoutingHandler | Renderers/{*pathInfo} | System.Web.Routing.RouteValueDictionary
System.Web.Routing.StopRoutingHandler | {*all_css_aspx} | System.Web.Routing.RouteValueDictionary
System.Web.Routing.StopRoutingHandler | {*all_js_aspx} | System.Web.Routing.RouteValueDictionary
Composite.Core.Routing.PageNotFoundRouteHandler | {*url} | 
So, it seems that the call of the method GleamTech.FileUltimate.FileUltimateConfiguration.RestoreRoutes() have no effect. The 5 FileUltimate routes are still missing.
 
One more indication:
 
If I clear all routes (RouteTable.Routes.Clear()) before calling (with the original Core dll)
GleamTech.FileUltimate.FileUltimateConfiguration.RestoreRoutes();
In development : I have the 5 FileUltimate routes created.
On production :  No route.
 
Thank you again in advance for your response.
 
Kind regards.
 
 
0
Cem Alacayir Replied
Employee Post
Ok I guess I understand the problem:
 
My WebSite is in WebSite mode not in WebApplication mode. 
It seems PreApplicationStart is not executed for some reason in WebSite mode when you deploy to production. I will examine this issue however there is a workaround which I think you can use in the meantime.
 
Forget about RestoreRoutes because it's not only about routes, the other initialization code is also not executed. Instead insert these lines in your Application_Start method of Global.asax:
 
FileUltimateConfiguration.PreApplicationStart();
DocumentUltimateWebConfiguration.PreApplicationStart();
WebConfiguration.OnApplicationStarted();
This should mimic assemblies' automatic PreApplicationStart attributes.
 
 
0
SHARPDEV SPRL Replied
Cem,

Your workaround is working! My template is working like a charm!

Again many thanks for your support!

Kind regards.
0
Stefano Cadò Replied
Hello,
I figured out the same problem on building a widget for Orchard CMS.
 
I try to follow the above steps by adding the three line into Application_Start method of Global.asax but that doesn't solve the problem.
 
I'm using the MVC version of FileUltimate.
 
Please, can you help me to solve the problem? I need it for a production web application.
 
Thanks and Best regards,
Stefano.
0
Stefano Cadò Replied
If can help, GleamTech.FileUltimate.FileUltimateConfiguration.AssemblyResourceStore is null
0
Cem Alacayir Replied
Employee Post
For future reference, after v5.2.0, these lines should be inserted in Application_Start method of Global.asax:
 
FileUltimateConfiguration.PreApplicationStart();
DocumentUltimateWebConfiguration.PreApplicationStart();
GleamTechWebConfiguration.OnApplicationStarted();
Note the yellow highlighted new class name, in my previous reply it was WebConfiguration but now it's called GleamTechWebConfiguration.
 
 

Reply to Thread