0

I installed RouteJS for MVC 5 via NuGet and followed the installation instructions, but the contents of _Layout.cshtml and a status of 200 is returned when attempting to load <script src='/routejs.axd/251810a87f19ffe842a619acc9a90d73349ba4fa/router.js'></script>.

I'm running MVC 5, C#, and IIS Express 8. I've tried a new variations of the Web.config that I found on its GitHub / NuGet website. Is additional configuration required if I'm using areas?

#_Layout.cshtml
#This works
<script src="@RouteJs.RouteJsHandler.HandlerUrl"></script>

#Web.config
<configSections>
    <section name="routeJs" type="RouteJs.RouteJsConfigurationSection, RouteJs" />
</configSections>

#This section by itself will break the application.
#Added the 'validation' line to system.webServer to prevent an error
#I've tried running RouteJS with and without this section.
<system.web>
    <httpHandlers>
        <add verb="GET" path="routejs.axd" type="RouteJs.RouteJsHandler, RouteJs" />
    </httpHandlers>
</system.web>

<system.webServer>
    <handlers>
        <validation validateIntegratedModeConfiguration="false"/>
        <add name="RouteJs" verb="GET" path="routejs.axd" type="RouteJs.RouteJsHandler, RouteJs" />
    </handlers>
</system.webServer>

<routeJs exposeAllRoutes="true" />

#RegisterRoutes
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
i3arnon
  • 113,022
  • 33
  • 324
  • 344

1 Answers1

0

You have to declare this kind of code for the area in order to add the route:

public class AdminAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "Admin";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "Admin_default",
                "Admin/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional }
            );
        }
    }
clement
  • 4,204
  • 10
  • 65
  • 133
  • I have the area setup for MVC. I didn't know if additional configurations were necessary for RouteJS because I'm using areas. –  Apr 29 '15 at 13:24
  • could you try to use routejs without area? – clement Apr 29 '15 at 13:52
  • RouteJS worked when I created a default MVC application without areas. I'm going keep going with this application and see when it breaks. –  May 03 '15 at 16:07
  • RouteJs isn't working because I have context.MapRoute with a url of "{*url}", because I'm building a single page app. Do you know if it's possible to have {*url} with an exception of routejs.axd? –  May 04 '15 at 00:05
  • you can catch uncatched exception in global.asax if you want, see this http://stackoverflow.com/questions/584199/unhandled-exceptions-with-global-asax , it may help you... – clement May 04 '15 at 06:15