How to route EVERYTHING other than Web API to /index.html
Use a wildcard segment:
routes.MapRoute( name: "Default", url: "{*anything}", defaults: new { controller = "Home", action = "Index" });
Suggest more native approach
<system.webServer> <httpErrors errorMode="Custom"> <remove statusCode="404" subStatusCode="-1"/> <error statusCode="404" prefixLanguageFilePath="" path="/index.cshtml" responseMode="ExecuteURL"/> </httpErrors></system.webServer>
in my case none of these approaches worked. i was stuck in 2 error message hell. either this type of page is not served or some sort of 404.
url rewrite worked:
<system.webServer> <rewrite> <rules> <rule name="AngularJS" stopProcessing="true"> <match url="[a-zA-Z]*" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" /> </conditions> <action type="Rewrite" url="/" /> </rule> </rules> </rewrite> ...
notice i matched on [a-zA-Z] because i don't want to rewrite any of the .js .map etc urls.
this worked in VS out of hte box, but in IIS you may need to install a url-rewrite module https://www.iis.net/downloads/microsoft/url-rewrite