3

My development background is in ASP .NET webforms. I've been reading various SPA tutorials but they always get into the weeds about specific javascript libraries.

I'm just trying to understand what happens in an SPA with a .NET middle tier.

Specifically:

Does the domain model exist both in .NET and javascript?

Is the javascript model more of a view model than a complete domain model?

Does this eliminate the need for views in the context of ASP MVC? ie. Does making an SPA basically turn ASP MVC into ASP MC?

Does the .NET layer only send data (JSON/XML) to the client? No markup?

Does all the ASP MVC routing configuration become largely irrelevant? Is all the routing handled client side?

closed as too broad by user40980, Scant Roger, Ixrec Nov 27 '15 at 21:22

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

7

So, I'm more experienced in PHP and Python but my answers should be valid for ASP .NET too, seen that your questions are more about the MVC structure rather than the language / framework itself.

First of all, the choice of the javascript library may be crucial to answer your questions. For instance, if you choose the full MeteorJS stack (where models are shared between the server and the client) or just a front-end library like Angular or React (or a combination of both).

Does the domain model exist both in .NET and javascript?

It might: depends on the library. The data is normally received as a JSON object via an XMLHttp call (or websocket, for a Meteor App) or directly accessed from the local storage. Implementing a model could be useful to keep your code clean (in Typescript you could use an interface) but for handling CRUD operations it really depends on the JS library of your choice.

Is the javascript model more of a view model than a complete domain model?

In a SPA you normally have Controllers (or "components", or "directives"), not view models. Again, it really depends on the JS framework / library. In the latest Angular 2.0 iteration the component is both a view and a controller. For more infos: https://www.youtube.com/watch?v=g9GgByAy80s

Does this eliminate the need for views in the context of ASP MVC? ie. Does making an SPA basically turn ASP MVC into ASP MC?

Yes, if you plan to use ASP as a RESTful API endpoint you still need controllers for routing and Models for CRUD: ideally, the "View" is just a JSON document.

Does the .NET layer only send data (JSON/XML) to the client?

Yes, but it should also be able to handle requests for CRUD operations (GET, POST, UPDATE, DELETE for REST, others for the DDP protocol)

No markup?

What kind of markup do you want to send?

Does all the ASP MVC routing configuration become largely irrelevant? Is all the routing handled client side?

As stated before, you'll still need routing to handle REST / DDP business logic. Everything else (like URL routing that the user can interact with in the browser bar) is managed by the SPA (and of course, the usage varies depending on your library choice)

Not the answer you're looking for? Browse other questions tagged or ask your own question.