title: DurandalJS Routing Behavior
body: <p><strong>What I Have</strong></p>
  
  <p>Trying to understand what's going on and how to control it.  I have a "public" view for users that have not yet been authenticated, and a "home" view for users that are authenticated.  Here's my route config: </p>
  
  <pre><code>app.start().then(function() {
          //Replace 'viewmodels' in the moduleId with 'views' to locate the view.
          //Look for partial views in a 'views' folder in the root.
          viewLocator.useConvention();
  
          //configure routing
          router.useConvention();
  
          router.mapRoute('home', 'viewmodels/home', 'Test App', true);
          router.mapRoute('public', 'viewmodels/public', 'Test App', true);
          router.mapRoute('set/:id', 'viewmodels/set', 'Set');
          router.mapRoute('folder/:id', 'viewmodels/folder', 'Folder');
          router.mapRoute('api', 'viewmodels/api', 'API Reference');
          router.mapRoute('error', 'viewmodels/error', 'Error', false);
          app.adaptToDevice();
  
          //Show the app by setting the root view model for our application with a transition.
  
          if (dataservice.isAuthenticated() === true) {
              app.setRoot('viewmodels/shell', 'entrance');
              router.navigateTo('home');
          } else {
              app.setRoot('viewmodels/public');
              router.navigateTo('#/public');
          }
  
          router.handleInvalidRoute = function (route, params) {
              logger.logError('No route found', route, 'main', true);
              router.navigateTo('#/error');
          };
      });
  </code></pre>
  
  <p><strong>The Problems</strong></p>
  
  <p>When I run the app for the first time, I'm not authenticated, and I get an error: </p>
  
  <pre><code>Uncaught TypeError: Cannot call method 'lookupRoute' of undefined 
  </code></pre>
  
  <p>Originating from the <code>'router.navigateTo('#/public');'</code> line. </p>
  
  <p>Then when I try to click the login button, I get the same error from this: </p>
  
  <pre><code>define(['durandal/app', 'durandal/plugins/router', 'services/dataservice'], function (app, router, dataservice) {
     var publicViewModel = function () {
          self.logIn = function () {
              app.setRoot('viewmodels/shell');
              router.navigateTo('#/home');
          };
  </code></pre>
  
  <p>But the content loads correctly.  When I navigate to a particular page by clicking, say to /folder/2, and then change the url to /folders/2 (invalid), I get "route not found" in my log, as expected, but I run into a few other issues:</p>
  
  <ol>
  <li>I don't get the error page, or any errors (as I think I should, per my handleInvalidRoute)</li>
  <li>If I click on something else, the url doesn't change, and new content isn't loaded, again with no errors.  </li>
  </ol>
  
  <p>I think I'm breaking routing somehow, but I'm not sure how.  How can I correct the above issues?  </p>
  
  <p>Screen: </p>
  
  <p><img src="https://i.stack.imgur.com/HyrdS.png" alt="enter image description here"></p>