We have to make IIS fall back to index.html by adding a rewrite rule.
Step 1:
Install IIS URL Rewrite Module
Step 2:
Add a rewrite rule to web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="AngularJS Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="https://stackoverflow.com/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>