Sitefinity 7.2 - false 404s

Posted by Community Admin on 04-Aug-2018 22:42

Sitefinity 7.2 - false 404s

All Replies

Posted by Community Admin on 29-Sep-2014 00:00

Since updating to 7.2 I'm receiving false 404s from Sitefinity, with MVC widgets.

I have an MVC widget at this address:

www.ozsoft.com.au/.../

That widget's controller has an action called "Course" on it, that takes an int as a parameter.  If I modify the URL to:

www.ozsoft.com.au/.../407

I get a 404 returned. This is obviously incorrect, that URL is perfectly valid.  I assume this is to do with this supposed "fix":

feedback.telerik.com/.../137924-invalid-urls-are-resolved-if-you-have-an-mvc-widget-on-the-page

Has anyone else experienced this? Anyone have any ideas?

Posted by Community Admin on 30-Sep-2014 00:00

Try overridding the HandleUnknownAction method in your controller. There's a bit of an explanation here: HandleUnknownError post. From what I have been seeing, actions not called 'Index' will never get the same routing as in a regular MVC application. 'Index' is always called, regardless of the URL. I think Sitefinity is missing the 'course' action and looking for a page with that URL.

I've used the HandleUnkownAction method then used the below code to handle multiple parameters in the URL.

List<string> segments = RouteHelper.SplitUrlToPathSegmentStrings( Request.Url.LocalPath, true ).Skip(1).ToList();

Posted by Community Admin on 30-Sep-2014 00:00

Hi Steve,

 Thanks for the help.

From what I have been seeing, actions not called 'Index' will never get the same routing as in a regular MVC application. 'Index' is always called, regardless of the URL. I think Sitefinity is missing the 'course' action and looking for a page with that URL.

This is actually exactly how Sitefinity worked before the upgrade to 7.2.  If you check the page now, I've actually rolled back the upgrade and you can see that the controller/action routing is working very well based on the URL supplied.  This is how MVC is supposed to work, so I'd be very surprised if Sitefinity's implementation deliberately chose to omit this behaviour.

I'm pretty sure this is a bug that was introduced with this fix:

MVC Support:Invalid URLs are resolved if you have a MVC widget on the page (FP). DISCLAIMER: As a result of this fix Sitefinity is now returning “Error 404”, therefore some of the links to your site might be broken. Note that you might revert the fix by overriding the InitializeRouteParameters method of the ControllerActionInvoker class and placing the RouteHelper.SetUrlParametersResolved(); after the invocation of the base InitializeRouteParameters method. 

www.sitefinity.com/.../sitefinity-7-2-released

It appears as though Sitefinity is incorrectly identifying the URL as "invalid".  I think that's where the bug lies - so the 404 is deliberate and working as intended, but the URL being identified as invalid is where the bug lies.

Posted by Community Admin on 05-Nov-2014 00:00

The 7.2 upgrade hosed my SF MVC widget controllers with 404 -  I had multiple actions per controller and had been relying on HandleUnknownAction to identify specific actions.  I got it working with 7.2 as follows.

1. Create a custom ControllerActionInvoker:

 

using Telerik.Sitefinity.Mvc;
using Telerik.Sitefinity.Web;
 
namespace SitefinityWebApp.Mvc
    public class MvcControllerActionInvoker:ControllerActionInvoker
    
        protected override void InitializeRouteParameters(Telerik.Sitefinity.Mvc.Proxy.MvcProxyBase proxyControl)
        
            base.InitializeRouteParameters(proxyControl);
 
            // Always mark as resolved (no 404'S)
            RouteHelper.SetUrlParametersResolved();
        
    

2.  Inject the custom ControllerActionInvoker via IOC in global.asax

protected void Application_Start(object sender, EventArgs e) 
     Bootstrapper.Initialized += OnBootstrapperInitialized;
 
protected static void OnBootstrapperInitialized(object sender, ExecutedEventArgs e)
     switch (e.CommandName)
          case "Bootstrapped":
               // override IOC
               // "MvcControllerActionInvoker" is the name of my custom
               // ControllerActionInvoker, above.
               ObjectFactory.Container.RegisterType<IControllerActionInvoker, MvcControllerActionInvoker>(
                  new InjectionMember[0]);
               break;
     

more injection points can be found by running JustDecompile on Telerik.Sitefinity.Abstractions -- check out ObjectFactory.RegisterCommonTypes()

Posted by Community Admin on 20-Feb-2015 00:00

Thank you so much, I just encountered this exact issue and you saved my bacon.

This thread is closed