Doubts about routes Angular JS x ASP.NET MVC

Asked

Viewed 160 times

2

I would like to clear up some doubts about Angular JS x ASP.NET MVC.

Created an empty ASP.NET MVC application that will work with WEB API, configured all my routes with Angularjs, created an html page and its controllers, everything with Angularjs, my question is the following, these routing between pages is sent some request to the server ? if the page has something to be loaded as a registration list via the $http.get method the request is made via ajax, that is to say the page is not loaded?

I was in this doubt, because in ASP.NET MVC all controller calls are called a request on the server, because Razor has to build the views and then present to the right user?

Someone with an understanding of the subject could describe more about the advantages of using the routing by Angularjs and ASP.NET MVC ?

1 answer

4


First of all, a brief explanation about the two technologies:

About the Angularjs

He is a framework to write applications client-side. Where you develop Javascript and everything developed there will run on the client side (on browser).

Most of the time, only send/receive data and, therefore, if it uses some other technology server-side (as a C# application with ASP.NET, a Ruby application, or any other).

For example, requests are made to the server and the server responds with data only (whether in JSON, XML, plain text or any other available type). These data must be processed on the client side.

Of course nothing prevents you from getting the server to return an HTML or something similar, keep in mind that what I say is how it normally works, there are no rules that really restrict it.

About ASP.NET MVC

Is a web framework to work on the server side, receive, handle and respond to requests.

Most of the time the requests are made to the server and it responds with a page already assembled, that is, all the data processing is done on the server side and sent to the client.

Of course there may be customer-side data processing, using Javascript, but there’s another story.

Now, let’s get to your questions:

These cross-page routing is sent some request to the server?

No. The idea is precisely that no (almost) contact with the server is made when changing the exchange (the state) of the application.

If the page has something to load as a log list via method $http.get the request is made via Ajax, or the page is not loaded?

Exactly. This is the purpose of asynchronous requests.

I was in that doubt, because in ASP.NET MVC all calls from controllers is called a request on the server, because the Razor have to build the views and then present to the right user?

Obviously. ASP.NET is a web framework to the server.

Basically, think about the following flow.

  • The browser requests a page

  • The server receives the request and sends it to the ASP.NET MVC application

  • The application handles the request, delegates the execution to a controller who, in turn, delivers the execution into the hands of Razor which will execute the entire code of the view and deliver a cute HTML to browser interpret

  • The browser receives the response and shows the HTML to the user

  • This is repeated as many times as necessary

Someone with an understanding of the subject could describe more about the advantages of using the routing by Angularjs and ASP.NET MVC?

I’m no expert on the subject, but I can tell you there’s no point in using it on each other. Each of them serves a specific purpose and they are completely different.

If the app is a SPA that only needs to query data on the server (at least most of the time), you will probably need to use the Angularjs route system. If it is a normal application, where most requests to the server will return a full page, it is likely to be preferable to use standard routing.


Indicated Reading:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.