How do I exclude a route from being processed by sitecore or glassmapper?
Trying to load a standard MVC route (controller/action). I do not want sitecore to handle it. I see this error:
Attempt to retrieve context object of type 'Sitecore.Mvc.Presentation.RenderingContext' from empty stack.
Using Sitecore 8.
The IgnoreUrlPrefixes setting should handle this.
Just add the route prefix in there and Sitecore should ignore it.
<setting name="IgnoreUrlPrefixes" value="....|/yourcontroller"/>
More info here
http://www.sitecore.net/learn/blogs/technical-blogs/john-west-sitecore-blog/posts/2012/06/four-ways-to-process-mvc-requests-with-the-sitecore-aspnet-cms.aspx
You can use MVC route Attributes to manage your regular routes. To do that you'll need to inject a little processor in sitecore initialize pipeline.
public class RegisterMvcAttributeRoutesPipeline
{
public void Process(PipelineArgs args)
{
RouteTable.Routes.MapMvcAttributeRoutes();
}
}
And then you need to inject your processor:
<sitecore>
<pipelines>
<initialize>
<processor type="{Your processor type here}" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeControllerFactory, Sitecore.Mvc']" />
</initialize>
</pipelines>
</sitecore>
And now you are ready to use route attributes:
[RoutePrefix("category")]
public class CategoryController : Controller
{
[HttpGet]
[Route("get/{id}")]
public ActionResult Get(string id)
{
return Content("MVC url with route attributes");
}
}
Cheers, Alex.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With