0

I'm trying to configure routes in MVC5, when i tried to refresh web-page withing angular 4 route it gives me

Server Error in '/' Application.
The resource cannot be found.

how can i config mvc routes to accept also angular routes:

  routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

  routes.MapRoute(
      name: "Default",
      url: "{controller}/{action}/{id}",
      defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
  );
Ehsan Sajjad
  • 61,834
  • 16
  • 105
  • 160
Fares Ayyad
  • 383
  • 1
  • 3
  • 18

1 Answers1

0

Add following rewrite rule to your web.config

<system.webServer>
<rewrite>
<rules>
<rule name="Main Rule" 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="/" />
</rule>
</rules>
</rewrite>
</system.webServer>

Hope this help you.