+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Sitefinity 7.2 - false 404s

Sitefinity 7.2 - false 404s

5 posts, 0 answered
  1. Nick
    Nick avatar
    15 posts
    Registered:
    30 Oct 2013
    29 Sep 2014
    Link to this post

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

    I have an MVC widget at this address:

    https://www.ozsoft.com.au/support-and-training/accredited-vettrak-user-training/individual-application/

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

    https://www.ozsoft.com.au/support-and-training/accredited-vettrak-user-training/individual-application/Course/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":

    http://feedback.telerik.com/Project/153/Feedback/Details/137924-invalid-urls-are-resolved-if-you-have-an-mvc-widget-on-the-page

    Has anyone else experienced this? Anyone have any ideas?

  2. Steve
    Steve avatar
    3 posts
    Registered:
    12 Jun 2012
    30 Sep 2014 in reply to Nick
    Link to this post

    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();

  3. Nick
    Nick avatar
    15 posts
    Registered:
    30 Oct 2013
    30 Sep 2014 in reply to Steve
    Link to this post

    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. 

    - http://www.sitefinity.com/developer-network/forums/general-discussions-/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.

  4. David
    David avatar
    1 posts
    Registered:
    05 Jun 2013
    05 Nov 2014 in reply to Nick
    Link to this post

    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()
  5. Joe
    Joe avatar
    21 posts
    Registered:
    01 Dec 2010
    20 Feb 2015
    Link to this post
    Thank you so much, I just encountered this exact issue and you saved my bacon.
5 posts, 0 answered