Problem with Http routes in 1.8 version

Topics: Announcements, Customizing Orchard
May 4, 2014 at 2:58 PM
I am doing ajax call from the view (in my customized theme) and it is working fine in version 1.7.1
@using (Script.Head()) {
    <script type="text/javascript">
        //<![CDATA[
        var path = "Themes/Gorizont/Styles/images/";
        var schemeApiUrl = '@HttpUtility.JavaScriptStringEncode(Url.RouteUrl("Schemes", new { httproute = "" }))';
        
        $(document).ready(function () {
            $.ajax({
                url: schemeApiUrl,
                type: 'GET',
                dataType: 'json',
                ...
            });
The route is described as usual
public IEnumerable<RouteDescriptor> GetRoutes() {
            return new[] {
                            new HttpRouteDescriptor {
                                                Priority = 90,
                                                Name = "Schemes",
                                                RouteTemplate = "Schemes",
                                                Defaults = new {
                                                    area = "Gorizont.ContentParts",
                                                    controller = "Scheme"}
                            }
and there is an api-controller in the project
public class SchemeController : ApiController {
        private readonly IApplicationList _applicationList;
        
        public SchemeController(
            IApplicationList applicationList) {
            _applicationList = applicationList;
        }

        public IEnumerable<SchemeItem> Get()  {
            return _applicationList.GetSchemeItems().ToList();
        }

    }
I repeat it's working in version 1.7.1. But after upgrade to 1.8 I've got this
Server Error in '/' Application.
A route named 'Schemes' could not be found in the route collection.
Parameter name: name
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: A route named 'Schemes' could not be found in the route collection.
Parameter name: name
Source Error:
Line 5:
Line 6: var path = "Themes/Gorizont/Styles/images/";
Line 7: var schemeApiUrl = '@HttpUtility.JavaScriptStringEncode(Url.RouteUrl("Schemes", new { httproute = "" }))';
Line 8:
Line 9: $(document).ready(function () {

Source File: e:\Orchard.Source.1.8\src\Orchard.Web\Themes\Gorizont\Views\Parts.Common.Body-Page-url-homepage.cshtml Line: 7

Stack Trace:
[ArgumentException: A route named 'Schemes' could not be found in the route collection.
Parameter name: name]
System.Web.Routing.RouteCollection.GetVirtualPath(RequestContext requestContext, String name, RouteValueDictionary values) +2350599
System.Web.Mvc.RouteCollectionExtensions.GetVirtualPathForArea(RouteCollection routes, RequestContext requestContext, String name, RouteValueDictionary values, Boolean& usingAreas) +161
System.Web.Mvc.RouteCollectionExtensions.GetVirtualPathForArea(RouteCollection routes, RequestContext requestContext, String name, RouteValueDictionary values) +55
System.Web.Mvc.UrlHelper.GenerateUrl(String routeName, String actionName, String controllerName, RouteValueDictionary routeValues, RouteCollection routeCollection, RequestContext requestContext, Boolean includeImplicitMvcValues) +259
System.Web.Mvc.UrlHelper.GenerateUrl(String routeName, String actionName, String controllerName, String protocol, String hostName, String fragment, RouteValueDictionary routeValues, RouteCollection routeCollection, RequestContext requestContext, Boolean includeImplicitMvcValues) +100
System.Web.Mvc.UrlHelper.RouteUrl(String routeName, Object routeValues, String protocol) +146
System.Web.Mvc.UrlHelper.RouteUrl(String routeName, Object routeValues) +49
ASP._Page_Themes_Gorizont_Views_Parts_Common_Body_Page_url_homepage_cshtml.Execute() in e:\Orchard.Source.1.8\src\Orchard.Web\Themes\Gorizont\Views\Parts.Common.Body-Page-url-homepage.cshtml:7
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +272
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +121
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +145
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +695
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +382
System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +467
System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +155
System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model) +93
Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.ShapeTemplateBindingStrategy.Render(ShapeDescriptor shapeDescriptor, DisplayContext displayContext, HarvestShapeInfo harvestShapeInfo, HarvestShapeHit harvestShapeHit) in e:\Orchard.Source.1.8\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:151
Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.<>c__DisplayClass28.<Discover>b__15(DisplayContext displayContext) in e:\Orchard.Source.1.8\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:133
Orchard.DisplayManagement.Descriptors.<>c__DisplayClass5.<BoundAs>b__2(DisplayContext displayContext) in e:\Orchard.Source.1.8\src\Orchard\DisplayManagement\Descriptors\ShapeAlterationBuilder.cs:56
Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) in e:\Orchard.Source.1.8\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:185
Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Execute(DisplayContext context) in e:\Orchard.Source.1.8\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:94
Orchard.DisplayManagement.Implementation.DisplayHelper.ShapeExecute(Object shape) in e:\Orchard.Source.1.8\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:86
Orchard.DisplayManagement.Implementation.DisplayHelper.Invoke(String name, INamedEnumerable`1 parameters) in e:\Orchard.Source.1.8\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:44
Orchard.DisplayManagement.Implementation.DisplayHelper.TryInvoke(InvokeBinder binder, Object[] args, Object& result) in e:\Orchard.Source.1.8\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:29
CallSite.Target(Closure , CallSite , Object , Object ) +371
Orchard.Core.Shapes.CoreShapes.ContentZone(Object Display, Object Shape, TextWriter Output) in e:\Orchard.Source.1.8\src\Orchard.Web\Core\Shapes\CoreShapes.cs:274

Please any ideas why it could happen? I am working with VS 2012 Update 4 and Web Tools installed.
May 4, 2014 at 7:47 PM
think this is similar to this :
https://orchard.codeplex.com/discussions/540804
May 5, 2014 at 11:57 PM
Thanks for the lead.
Sebastien advised not to use named routes. Anybody can advise how to do it for Web Api case?