title: Angular2 in ASP.NET - Window is not defined
body: <p>I'm decently new to Angular2 and very new to incorporating it into an ASP.NET Web Application. 
  I got this error when I tried to build in debug mode in my Angular2 ASP.NET web application.  I got the same error when building in release mode.</p>
  
  <p><code>Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[0]
  An unhandled exception has occurred while executing the request
  Microsoft.AspNetCore.NodeServices.HostingModels.NodeInvocationException: Prerendering failed because of error: ReferenceError: window is not defined
      at D:\Projects\BryterOpsAdmin\BryterOpsAdmin\ClientApp\dist\vendor.js:89981:21
      at Object.&lt;anonymous&gt; (D:\Projects\BryterOpsAdmin\BryterOpsAdmin\ClientApp\dist\vendor.js:90732:3)
      at Object.&lt;anonymous&gt; (D:\Projects\BryterOpsAdmin\BryterOpsAdmin\ClientApp\dist\vendor.js:90734:30)
      at __webpack_require__ (D:\Projects\BryterOpsAdmin\BryterOpsAdmin\ClientApp\dist\vendor.js:21:30)
      at Object.&lt;anonymous&gt; (D:\Projects\BryterOpsAdmin\BryterOpsAdmin\ClientApp\dist\vendor.js:85385:1)
      at Object.&lt;anonymous&gt; (D:\Projects\BryterOpsAdmin\BryterOpsAdmin\ClientApp\dist\vendor.js:85386:30)
      at __webpack_require__ (D:\Projects\BryterOpsAdmin\BryterOpsAdmin\ClientApp\dist\vendor.js:21:30)
      at Object.&lt;anonymous&gt; (D:\Projects\BryterOpsAdmin\BryterOpsAdmin\ClientApp\dist\main-server.js:20466:42)
      at __webpack_require__ (D:\Projects\BryterOpsAdmin\BryterOpsAdmin\ClientApp\dist\main-server.js:20:30)
      at Object.exports.REPLACEMENT_CHARACTER (D:\Projects\BryterOpsAdmin\BryterOpsAdmin\ClientApp\dist\main-server.js:398:79)
  Current directory is: D:\Projects\BryterOpsAdmin\BryterOpsAdmin</code></p>
  
  <p>I had just made some insignificant changes to a model class on the mvc side, so when I got this error I reverted my changes and tried again.
  I still received this error.  According to my source control, there have been absolutely no changes since the last time it was working properly.
  What can be causing this error?  I'm completely stumped as to what to even try to look for.</p>
  
  <p>I searched StackOverflow for anything related but I didn't find anything that applied to asp.net other than this question: <a href="https://stackoverflow.com/questions/41462658/prerendering-failed-because-of-error-referenceerror-window-is-not-defined#">Prerendering failed because of error: ReferenceError: window is not defined</a>
  which was never answered.</p>
  
  <p>I tried deleting the hidden obj and bin folders to no avail.</p>
  
  <p>Thank you in advance.</p>
  
  <p>UPDATE:
  I tried navigating directly to a page on my site, which it did so successfully.  It seems that Angular2 is not longer automatically routing.  I'm still hitting the Home Controller and Home Index.cshtml view through MVC ('Home/Index'), so this seems like an Angular2 issue.</p>
  
  <p>This is what my angular2 routing looks like.  </p>
  
  <p>`</p>
  
  <pre><code>RouterModule.forRoot([
              { path: '', redirectTo: 'home', pathMatch: 'full' },
              { path: 'home', component: HomeComponent },
              { path: 'counter', component: CounterComponent },
              { path: 'fetch-data', component: FetchDataComponent },
              { path: 'bryterUsers', component: BryterUsersComponent },
              { path: 'adminUsers', component: AdminUsersComponent },
              { path: 'retailers', component: RetailersComponent },
              { path: 'providers', component: ProvidersComponent },
              { path: '**', redirectTo: 'home' }
          ])`
  </code></pre>
  
  <p>UPDATE2:  I now can no longer navigate to any other pages.  I get the 'window is not defined' error wherever I go.  I have changed nothing in my code.  I'm completely stumped.  Any help would be greatly appreciated.</p>