Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ric Carey 50 posts 93 karma points
    May 21, 2014 @ 11:56
    Ric Carey
    0

    Custom Route 404 Errors

    Does anyone know how you can get Umbraco to handle 404's of custom mvc routes? Is there a way to get it to redirect to the custom umbraco configured page? or do you just have to do like a generic catch all custom 404 page like in a straight mvc app?

    Having a quick look at the answers to an mvc 404 http://stackoverflow.com/questions/553922/custom-asp-net-mvc-404-error-page

     

    It looks like you'd have to change the httperrors from pass through, wont this have a knock on effect for the umbraco 404 handler?

     

     

  • Amir 75 posts 224 karma points
    May 21, 2014 @ 12:13
    Amir
    0

    Generally you can set the error node ID for 404 errors in umbracoSettings.config in config folder as below:

    <errors>
               <error404>2763</error404> <!--Your error Node  ID-->
    </errors>

     

    But recently I had some problem with this, so I decided to move it to IIS level:

    Select your site then

    ErrorPages -> Edit 404 and / or 500 to /YourErrorPageUrl.aspx

     

  • Amir 75 posts 224 karma points
    May 21, 2014 @ 12:15
  • Ric Carey 50 posts 93 karma points
    May 21, 2014 @ 12:35
    Ric Carey
    0

    @Amir

    Yeah I've implimented the usual Custom Umbraco 404 which works fine if say for example you go to an obvious page that doesnt exisit /sdfsdhfjbdfjsd

    However if you try and go to an action which is say  [AjaxRequest] on a get request, it returns the iis default 404 page.

    heres my custom route

     

        public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication,
                ApplicationContext applicationContext)
            {
                //Create a custom route

                RouteTable.Routes.MapRouteLowercase(
                  "Quiz Questions",
                  "quiz/{action}/{id}",
                  new
                  {
                      controller = "Quiz",
                      action = "Index",
                      id = UrlParameter.Optional
                  });

                
                WebApiConfig.Register(GlobalConfiguration.Configuration);

            }

     

    So if i went to /quiz/question/1234 for example it returns 404 which i want it to. I just dont want the iis default page. Im wondering is it possible to configure it to return the configured 404 page asif it wasnt a hijacked route?

Please Sign in or register to post replies

Write your reply to:

Draft