Posts

Showing posts from May, 2014

Handling the situation where scItemPath does not exist in Sitecore MVC

What happens if the scItemPath specified in your route does not exist in Sitecore? In this post i'm going to discuss how I handle this situation. Here is a sample route from Sitecore's MVC documentation .   (see Section 4.1) // matches the item '/home/blogPosts/{blogNo}' routes.MapRoute("example2", "blog/{blogNo}", new { scItemPath = "/home/blogPosts/{blogNo}" }); But what happens when the blog number doesn't exist?   What page will Sitecore show?  What if the user has a link to an old blog post that you have archived or someone links to a blog post using the wrong number by accident? What I wanted was a new route value that specified where to go when the path resolved by scItemPath is not found.  So I created the scNoItemFound value. // matches the item '/home/blogPosts/{blogNo}' routes.MapRoute("example2", "blog/{blogNo}", new { scItemPath = "/