AngularJS+MVC - Error 404 refreshing page
<p>I'm developing a web application using AngularJS (v1.4.9)+ASP.NET MVC.</p>

<p>I've enabled the html5mode for pretty links, but I've this problem: when I browse to my first page of the application (Login) and I try to refresh that page, for example with F5 button, I receive a 404 error.</p>

<p>I've searched on StackOverflow and found this discussion: <a href="https://stackoverflow.com/questions/30322892/angularjs-html5mode-page-refresh-breaks-the-routing-in-asp-net-mvc">Angularjs html5Mode page refresh breaks the routing in asp.net mvc</a> that it seems exactly like my scenario. But the solution suggested did not work for me.</p>

<p>This is what I've done at the moment:</p>

<p><strong>web.config</strong></p>

<pre><code>&lt;rewrite&gt;
     &lt;rules&gt;
       &lt;rule name="AngularJS Routes" stopProcessing="true"&gt;
         &lt;match url=".*" /&gt;
         &lt;conditions logicalGrouping="MatchAll"&gt;
           &lt;add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /&gt;
           &lt;add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /&gt;
         &lt;/conditions&gt;
         &lt;action type="Rewrite" url="/" /&gt;
       &lt;/rule&gt;
     &lt;/rules&gt;
   &lt;/rewrite&gt;
</code></pre>

<p><strong>_layout.cshtml</strong></p>

<pre><code>&lt;base href="/"&gt;
</code></pre>

<p><strong>app.js</strong></p>

<pre><code>.config(['$routeProvider', '$locationProvider',
function ($routeProvider, $locationProvider) {
   $routeProvider
       .when('/', {
           templateUrl: '/MyAppView/Login'
       })
       .when('/Login', {
           templateUrl: '/MyAppView/Login'
       })
       .when('/Home', {
           templateUrl: '/MyAppView/Home'
       })
       [...]

       .otherwise('/Login')

   $locationProvider.html5Mode({
       enabled: true
   })
}
</code></pre>

<p>also tried to use this code in</p>

<p><strong>RouteConfig</strong></p>

<pre><code>public static void RegisterRoutes(RouteCollection routes)
{
       routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
       routes.MapRoute(
       name: "Default",
       url: "{*url}",
       defaults: new { controller = "Home", action = "Index" });
}
</code></pre>

<p>Every time, when I start debug on VS, my browser loads the template (e.g. the background image), but it crashes just before loading the login view. I've tried to use Chrome/IE11/Edge.</p>