Copied to clipboard

Flag this post as spam?

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


  • Hua 9 posts 39 karma points
    Jun 02, 2016 @ 22:13
    Hua
    0

    Umbraco 7 Template rending as web pages

    Hi,

    I found Umbraco will generate Templates' name to be pages within the website.

    For example: I have a view 'Product.cshtml', and Umbraco will generate an Url http://www.xxx.com/product

    How to stop that? Any solutions?

    Thanks, Tony

  • Nik 1612 posts 7258 karma points MVP 7x c-trib
    Jun 02, 2016 @ 22:29
    Nik
    0

    Hi Tony,

    I believe what you are seeing is that when you go to domain/templatename it takes you to the home page but tries to render it with the template.

    This isn't exactly the same as it creating a url however, I'm not sure how you would stop this behaviour.

    I have to admit it isn't something I've seen before and it would be very unlikely for someone to find that url in the first place.

    Just out of interest, how did you identify this behaviour?

  • Nicholas Westby 2054 posts 7103 karma points c-trib
    Jun 02, 2016 @ 22:36
    Nicholas Westby
    1

    This is a side-effect of a feature in Umbraco called "alternative templates". Basically, if you have some page like site.com/some-page, you can force that page to render with a specific template by using the URL site.com/some-page/specific-template.

    There are a couple ways to disable this. One is to modify a setting to set disableAlternativeTemplates to true: https://our.umbraco.org/documentation/reference/config/umbracosettings/

    Another way you might try (I'm unsure if this will work or might break something) is to remove this line from 404handlers.config:

    <notFound assembly="umbraco" type="SearchForTemplate"/>
    

    Here is some further reading (haven't read it myself, but might be useful): http://www.codeshare.co.uk/blog/umbraco-alternate-template-feature-bug/

  • Hua 9 posts 39 karma points
    Jul 03, 2016 @ 23:44
    Hua
    0

    Hi Hicholas,

    Both ways are working. Awesome.

    Thanks Tony

Please Sign in or register to post replies

Write your reply to:

Draft