404 issue for Angular 2 routing

Problem

Angular 2 does not use "#" for routing anymore. Instead, all the parameters are separated by "/" only.

A big issue about using "/" is that our browser sends a new GET request based on the URL entered in the browser's address bar. It raises a 404 issue since the file based on the entered URL cannot be located.

Solution

Need to set up rewrite rule in IIS:

  1. Install IIS Rewrite extension from http://www.iis.net/downloads/microsoft/url-rewrite#additionalDownloads
  2. In IIS Manager, find the site using Angular 2 routing. Click URL Rewrite


    to add following rules :
    1. cfiles_allow

      client/(style/*|app/*|node_modules/*|index.html|index.cfm)

    2. cfiles_stop

client/(.*)

client/index.cfm

c. Allow desktopClient

(cfcs|css|desktopClient)/*

http://stackoverflow.com/questions/34955493/angularjs-2-routing

http://blog.angular-university.io/angular2-router/