Copied to clipboard

Flag this post as spam?

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


  • shinsuke nakayama 109 posts 250 karma points
    Nov 10, 2014 @ 07:37
    shinsuke nakayama
    0

    using template name in the URL shows error

    Hi guys,

    I am currently working on the 404 page not found and I noticed that if i have a Template name in the URL, it shows 500 Server error, instead of page not found.

    e.g. http://SomeUrl.com/template1

    I was expecting this will throw an 404 but it didn't, instead i got this error message

    "The model item passed into the dictionary is of type 'Umbraco.Web.Models.RenderModel', but this dictionary requires a model item of type 'projectNamceSpace.Template1ViewModel'."
    

    Since this is .net MVC, i thought it will goes through HomeController, as defined in the RouteConfig.cs. But it seems to bypass this configuration.

    Does anyone have any idea how to show 404? instead of error message?

    Thank you

    Shinsuke

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 10, 2014 @ 07:41
    Jan Skovgaard
    0

    Hi Shinsuke

    What exact version of Umbraco are you using? It might be a bug.

    /Jan

  • shinsuke nakayama 109 posts 250 karma points
    Nov 10, 2014 @ 08:09
    shinsuke nakayama
    0

    I'm using 7.1.8

  • shinsuke nakayama 109 posts 250 karma points
    Nov 10, 2014 @ 08:43
    shinsuke nakayama
    0

    It looks like same error with this one http://issues.umbraco.org/issue/U4-2691

    But it said it was fixed in version 6.2?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Nov 10, 2014 @ 12:14
    Jeroen Breuer
    0

    Hello,

    It will go to the HomeController, but when you're using an alt template it will go to a different ActionResult. For example if this is your HomeController:

    public class HomeController : SurfaceRenderMvcController
    {
        public ActionResult Home(RenderModel model)
        {
            //Do logic
    
            return CurrentTemplate(model);
        }
    }

    If you have a template called News for example and you want it to hit your HomeController you need to add this:

    public ActionResult News(RenderModel model)
    {
        //Do logic
    
        return CurrentTemplate(model);
    }

    It's also possible to disable alt template when you're using internal redirect. It's the internalRedirectPreservesTemplate attribute in the umbracoSettings.config file.

    Jeroen

  • shinsuke nakayama 109 posts 250 karma points
    Nov 10, 2014 @ 13:57
    shinsuke nakayama
    0

    Hi Jeroen,

    Thank you for your reply, I did try creating

    public ActionResult TemplateA(RenderModel model)
    {
        return CurrentTemplate(model);
    }
    

    But this didn't work. I even created a HomeController constructor but it didn't go through there either.

    However i did look up how to disable "alt template" and found a solution here

    http://our.umbraco.org/forum/templating/templates-and-document-types/50392-How-to-disable-TemplateName-altTemplate-behaviour-in-v6

    I didn't know about the "alt template" and how it worked, till you mentioned it in your post

    Thank you

    Shinsuke

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Nov 10, 2014 @ 14:10
    Jeroen Breuer
    0

    In your situation it might be better to disable the alt template if you don't need it. So just set the attribute to false in umbracosettings.config. Restart the website and after that it should go to the 404 page.

    Jeroen

  • shinsuke nakayama 109 posts 250 karma points
    Nov 10, 2014 @ 14:46
    shinsuke nakayama
    0

    Hi Jeroen,

    I did try set the value of "internalRedirectPreservesTemplate" to false, and restarted the web server but that didn't disable the alt template.

    I think its because in my scenario, people are coming to this page from external reference. such as google search or old EDM links?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Nov 10, 2014 @ 14:47
    Jeroen Breuer
    0

    It only disables alt template if the page has an internal redirect. Otherwise the solution from the other topic probably works.

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft