0

Is it possible to remove my ASP.net routing module and include angular routing and SPA features in my asp.net application?

Will there any benefits in doing the same?

SmartestVEGA
  • 8,415
  • 26
  • 86
  • 139
  • If you are talking about angulaJs then, hope it will help you. https://stackoverflow.com/questions/29903751/angularjs-routing-with-asp-net-mvc – Amit Kumar Sep 26 '17 at 11:13
  • I would be more curious about the benefits out of it rather than the implementation – SmartestVEGA Sep 26 '17 at 11:18

1 Answers1

0

I'm not sure if we are at the same page here, but I believe you misunderstand the purpose of each one. The routing feature of ASP.NET and that of Angular (or any SPA for that matter) are not competing technologies, they serve completely different purposes.

The responsibility of the ASP.NET router is to "route" the incoming requests to the server, simply put, to map URLs to controller actions.

The responsibility of the Angular (or any SPA router) is to "keep track" of your location inside the client application. This makes different things possible. For example, it allows you to share a link with your college so that (s)he will land at the same part of the app as you were when you shared the link. Compare that to regular DOM hackery, in which case, you simply hide/show elements according to user interactions. In that case (unless you ship your own solution to that problem), upon reopening the page, it will appear in its default state.

As you navigate through the client, it is the Angular router that is at play. However, a client-side SPA in most cases still needs data, which is served by some backend, perhaps an ASP.NET one. To make that happen, you need to do - for example - AJAX-calls to retrieve the data from the server. And this is the point the ASP.NET router comes into play, because it is that router that maps your AJAX-requests to appropriate controller actions. The only difference between this scenario and that of a regular website is that your controller actions are designed to serve (for example) JSON-consuming clients.

I hope that is a simple enough explanation to clear these up.

Balázs
  • 2,929
  • 2
  • 19
  • 34