Routing with Wildcard Item

I've been trying to use a few different implementations for wildcard items using MVC in Sitecore 8.1.  My needs are truly no different than a lot of the posts

that are out there.   I have a products details page that I need to get to using wildcard items (/products/*/*).  I've set up the wild cards as well as the 

item resolver.  All of this appears to works fine and my item is resolving.  However, I'm getting a document not found error...

What am I missing?  Should I be looking to abandon the wildcard items route all together?  


Thanks ahead of time.


12 Replies

  • Some thoughts/questions to help isolate this.
    1. How do you know your item is resolving?
    2. Your wildcard items do have presentation details right?
    3. Can you put a breakpoint in a view, and run in the VS debugger to see if your getting there?
    4. what happens when you navigate to /products/*/*? Do you get the same 404?
  • In reply to Paul Tiemann:

    Paul Please see my responses:

    1. How do you know your item is resolving? I'm able to step through the Item resolver code and can see that it's able to find the item and assign it to args.Result.
    2. Your wildcard items do have presentation details right? They do, and worked perfectly fine prior to changing names to "*"
    3. Can you put a breakpoint in a view, and run in the VS debugger to see if your getting there? In the scenario where this error is occurring, it does not hit the break point. Oddly enough, if the item resolver is null, the view renders fine, but of course with no actual context item.
    4. what happens when you navigate to /products/*/*? Do you get the same 404? if you mean literally, "/products/*/*" i get a potentially dangrous request.path error.

    Just to give you a little bit of a background. I've tried 2 different methods.. I've used Volodymyr Hil's refactored Wildcard Module ( on one approach, this is why i'm able to step through the code and see for certain the item is resolving. Also with the UI tool within Sitecore, I can see that the Url Generation and Item Resolving are working fine.

    The second approach, I simply created my own Item Resolver with just a simple check on the URL grab a hard coded item assigned it to args.Result and am experiencing the exact same issue.

    If you take another look at the "requested url" in the image i provided, what could be causing the spaces to appear in the url? The url that I used was "/products/UCM123456/nuts-and-bolts. But something seems to be effecting the URL. My first thought is that might be where the issue is, BUT even if I provide values in the url segments without dashes, the same result occurs.

    Thanks for the response.

  • Hi Chris,

    On Sitecore 8.x they have introduced pretty strange feature which contains a bug inside and prevents wildcards from normal resolving.
    Try to set a sitecore setting "ItemResolving.FindBestMatch" to "Disabled"
    <setting name="ItemResolving.FindBestMatch">
    <patch:attribute name="value">Disabled</patch:attribute>

    relevant issue here
    and here
    and here
  • In reply to Hil Volodymyr:

    Hi Volodymyr. I really appreciate you responding to my post on your blog..

    Unfortunately, this didn't seem to resolve the issue. I'm currently running 8.1 Update 3. I'm going to attempt a clean install using 8.1 Update 2 to see
    what kind of results I get. I'll keep all posted. Again thanks for the quick response.
  • In reply to Chris Brown:

    First, let me start by saying, thanks again to Volodymyr and Paul for your responses. Paul, i'd like to go back and say, for Item #2, my wildcard item (*), has presentation details, BUT the individual items, did not... Once I set presentation details for the items within my shared content folder, things started to work..

    Now, with that little bit of embarrassment for not catching that sooner out of the way , I'm still somewhat confused.

    Isn't the purpose of a wild card item (home/product/*/*) to allow for me to have a "single" presentation detail defined, my (*) page. And then the
    item resolved from the url will be used as the datasource for the "page"? Yes, Volodymyr, i realize now that's NOT how your module is designed to work..
    And the more I think about that in my head the more I realize resolving the MVC Page Item args.Result was NEVER going to function the way that I was thinking..

    My goal was two-fold.
    1 - have a shared content repo for all products,
    2 - have a common presentation for all products, HOWEVER, the common presentation details
    may differ from site to site / function... For example, if I wanted to provide an "embed" link for my products, the presentation details would be watered down and contain less (or even different) components.

    Site A Home
    - Products
    - * (Product ID)
    - * (Product Name) <-- Has Presentation Details Defined to display products one way

    Site B Home
    - Products
    - * (Product ID)
    - * (Product Name) <-- Has Presentation Details Defined to display products a different way

    - Products
    - Product A <-- Just data no presentation details
    - Product B <-- just data no presentation details

    This seems to fit within the mold of wildcard items, but i'm no longer certain that a different approach would not be better.

    Thanks again..
  • In reply to Chris Brown:

    Hi Chris! How does your route config look like?

  • In reply to Chris Brown:

    The issue with the presentation is being taken from your shared folder items is because of same issue with Sitecore 8.x - now setting the Rendering Page Item leads to chaning the Sitecore.Context.Item. This does not sound right. In Sitecore 7.2 the MVC rendering context has a Page Item which is not always equal to Context Item. And the presentation details are taken from the Context Item, in the same time you can have a different item in the Rendering Page Item.
    In 8.x this functionality is broken. So my module should work like you described once this issue is fixed.
  • In reply to Hil Volodymyr:

    Maybe need to look somewhere in pipelines where the Context Item is being set to Page Item and try to fix...
  • In reply to Chris Brown:

    Well Chris, I would have expected the wildcard presentation details would have worked too. :) Setting presentation details for each product seems like a lot of work, unless it's all in standard values. I'll be watching this as I need to implement something simular very soon for current project.You're beating down the trail ahead of me. Thanks!
  • In reply to Hil Volodymyr:


    Thanks my friend. I will spend some time looking through the pipelines. Hopefully I will find something out cause at this time, i believe that the direction I was attempting is a good course of action and your module makes it very easy and scalable without having to rework code every time a new route is needed.
  • In reply to Hil Volodymyr:

    This worked for me. => setting "ItemResolving.FindBestMatch" to "Disabled"

  • In reply to Chris Brown:

    Hi Chris. I know its been long time since this post. But I am facing the same issue you had mentioned. I have added a wildcard item (with presentation details) and the data source item is product item (which don't have presentation) . Now my context item is getting resolved as item which does not have presentation. Any idea how you solved it?