Angular $locationProvider with ASP.NET MVC routing

后端 未结 2 1749
小鲜肉
小鲜肉 2021-01-27 16:57

I\'m handling routing using ASP.NET MVC (using RouteCollection class). But my front end is written in angular and at some places I want to change url using Angular\'s $location

2条回答
  •  生来不讨喜
    2021-01-27 17:16

    No unfortunately not. If your angular SPA is hosted at foo.com with HTML 5 mode on, foo.com/spaRoute1 will hit your ASP.Net server and expect to find that route (likely controller=SpaRoute1 action=Index).

    You will need to set your default route to always resolve to the controller/action that is responsible for serving up your SPA. All while defining any other routes that you need which are not specific to your SPA.

提交回复
热议问题