We have a project using ASP.NET MVC 4 and it is a multi page mvc web app. We are planning to use Backbone js as the front end javascript framework . What is the best practice or suggestion to organize the backbone js code for the multi page mvc web app?
How it will be organized if we use Knockout js instead of backbone js.?
Thanks,
Sarathy
In my experience, Backbone is best used for SPA's (Single page apps). It is designed to help bring structure to javascript heavy applications. You first need to tell us why you are looking to use either of these libraries and a description of the site or app you are building? Are you using MVC 4 Web API, because Backbone connects to your existing API over a RESTful JSON interface and Web API is a perfect fit for this.
The only reason I would see to use Backbone for a multi-page mvc web app, is if you are looking for the app to function with javascript disabled and progressively enhance the app with Backbone. If you are looking to use pushstate, then you would also need to serve the individual pages.
I think the best bet is to look at TODOMVC to get a feel of the different libraries. Look how they work and see which, if any, would be a good fit for your app.
Related
I have a newbie question. If we use React (or any other similar framework) in ASP.NET MVC we end up with very simple (single?) cshtml file which delegates UI rendering to React. So in that case, why bother with MVC? Shouldn't be a better idea to create WebAPI REST service, and a frontend client application in pure JavaScript/React as two completely separated applications?
I just don't get the idea of using ASP.NET MVC in combination with different frontend frameworks...
So basically you're correct in that you would not use a typical MVC setup when using something like React or Angular. That said with the newer versions of ASP.NET there is no difference between an API controller and an MVC controller. You'd write your API endpoints in this new unified controller and use it like a standard RESTful API for your React application to hit. You can keep both in the same solution and serve up the index.html to start your web application.
In my experience it is better to just separate the two entirely and built a .Net back end in one VS solution and then use something like WebStorm to write your web application in another.
Compared to pmanderson54's answer, he is right about separating .NET back end and React Front end apps.
Just don't forget to configure enabling Cross-origin Requests in Web Api
https://learn.microsoft.com/en-us/aspnet/web-api/overview/security/enabling-cross-origin-requests-in-web-api
So I just spent the past 5 hours reading up on Angular JS. It seems like a lot of people are heavily associating this framework to single page applications especially when accommodated with a back-end MVC framework with nice API usage like Ruby on Rails or Laravel.
I have 2 main questions that have been boggling me:
How do you initialize such apps considering that the content is
dynamic in nature. When using something like RoR/Laravel, I'd prepare
the HTML with the dynamic data at the back-end and then serve the
initial pages. It seems like most people using Angular serve up a
basic skeleton of the HTML and then do a round trip to web server
again for some data. Is this really how its done? if not, please
suggest a the right way.
Secondly, I dont think I am about to embark on a project with a
single paged application in mind. Does that mean it would be overkill
to use AngularJS for my project. Does anyone have a use case that
they think is appropriate that would require AngularJS with non
single page application that jQuery cant handle easily?
I am building an app with following technologies
1. RoR - BackEnd
2. Angular JS - FrontEnd
In this case RoR should handle all the backend stuff (Model and Controller) and Angular JS should handle the stuff which should with handled by RoR View. So my question is that how we can communicate between these two different technologies. If possible, also suggest some tutorials for the same.
AngularJS is the client side JavaScript Framework and it works on the MVC design pattern. while Ruby on Rails is a server-side application framework based on MVC design pattern. The points below is a quick representation of how Angular JS works seamlessly with RAILS MVC.
The power of Angular JS is the client side data manipulations which we use for various User Interface Use Cases like Lists, Refine Search, and Graphical Data Representation etc and present the Web Application to the user as a Single Page Application.
Building the single-page applications using Angular JS and Ruby on Rail is a two-step process: first, you create a JSON API in Rails and then you use that API in the JavaScript application.
The Angular JS Controllers interact with RAILS Controllers. The object data from the RAILS Model (M) is passed to the Angular JS Controllers via Rails Controller(C) using Restful API services. The view part of the application is the Angular JS framework in MVC design pattern, dropping the View in Rails.
This way the true potential of Angular JS is utilized for building the Single Page Application and Rails is capitalized for its server-side implementation using its Models and Controllers. The layers interact using Restful JSON API services. Hire a ruby on rails developer for more detailed information.
I am new to Javascript and have started watching some Backbone.js tutorial on youtube. I have a background of working on Backend where I developed web-services.
I want to learn to develop websites using framework like backbone.js/angular.js
To start with, you should know how these framework helping you to create the Single Page Application. Take for example angularjs,
ng-view
Routing Concept.
Ajax Support like $http service.
Your back-end APIs
Creating sample Single Page Application here. Some concerns with single page application are mentioned in these two blogs.
Memory Management in Single Page Application
Designing Model
for Single Page Application
I am developing a Java web services application that is (mostly) to be used by other SOA clients. Currently I am planning on using CXF to publish my various web services & methods using SOAP/XML.
I am now being asked to investigate a thin client web-application for this tool. I have been looking into Javascript libraries such as ExtJS and Dojo -- and they seem really straightforward. Given that this is a web application and not a web site, I really don't think I'll be creating very many static HTML pages -- maybe even just one. Mostly I plan on using an XMLHttpRequest object to hit the web services I already have and take the results and modify the DOM.
However, I have never created a browser-based UI before and in the context of a nearly 100% Javascript application I am trying to figure what role, if any, a server side MVC framwork such as Spring MVC will buy me. Is it needed for this? Whats it good for?
If you use the CXF JavaScript client generator and go for a single page JS application, I don't see what a Java MVC framework will give you (apart from extra complexity).
Spring MVC is a web-based module based on servlets and JSPs. If you're writing a JavaScript UI that calls on services directly, I'd say that you don't need Spring MVC.