Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC 4 SPA (Single Page Application) clarification

I've been reading a MVC 4 SPA at http://www.asp.net/single-page-application/an-introduction-to-spa.

Even after reading I'm bit unclear on what scenario should I use SPA. By looking at few examples on above link, looks like the Controllers remain the same. Is it the difference between MVC Web Page vs SPA is that SPAs contain lots of Javascript frameworks? And if we use these Java Script frameworks (Jquery, Knockout, Upshot etc) with MVC Web, we can achive the same result as SPA? OR SPA means ONE page for whole web application?

Also, do we stull use layout pages for SPA?

Thank you for clarifing. Hope someone's not going to - vote.

like image 304
Nil Pun Avatar asked Apr 29 '12 10:04

Nil Pun


1 Answers

So from My Understanding SPA is just a project template that shows a pattern for creating a Single Page Application. You could do this in previous version of MVC but MVC 4 has some more tools to make it easier and show the pattern.

An example of this would be trello.com. When you use the software it doesn't feel like a regular web site where you have requests and responses in which the page refreshes. Everything is done on the client side using a javascript framework like the ones you mentioned.

Your controllers build out a data api (hence the new api controller) which allows you to peform actions on the server and return raw data in JSON or you could return html if needed.

But every call back to the server would be an AJAX call through your client side framework. You would never use a regular tag which would direct you do a different page and do an entire page refresh.

So ta scenario in which you would use SPA is if you were creating some kind of web app (like trello) in which you wanted it to really feel like a desktop application.

like image 137
Brett Allred Avatar answered Oct 09 '22 00:10

Brett Allred