Search code examples
c#asp.netasp.net-mvcknockout.jssammy.js

MVC 5 Single Page Application Template


So I got a full working project generated for me, it does the registration and login process very good.

Now I want to add a button on the page that should display a list of customers. the old way of adding a controller and views in folders with the controller name etc.. works great, but that's not SPA.

So I guess I have to create an APIController and not a regular controller. but how do I navigate to it? how do I need to name it so sammy picks it up? where do I put the views? all in one file or separate files?

I've spent hours upon hours finding some guidance on how to make the generated SPA template do something useful. all the help articles [including the one linked from within visual studio 15] reference some older version of the template that does not match the one generated for me. I've read a lot of knockout and sammy articles, but I'm not sure how to put everything together in a way asp.net expects it.

I really hope someone here could guide me on how to get started, or link to an helpful article. a complete project that shows some navigation [using MVC5, Knockout, Sammy, Entityframework] would be best.


Solution

  • After days of research I found that site that generates much better templates, with the option to use angular2, Knockout or React. these templates include routing, styling and all packages setup out of the box. [would be nice if they would add authentication, entityFramework and MVC views to the mix too..].

    These templates are not done from Visual Studio at the moment, but are very easy to get done using the following script in the cmd prompt:

    cd some-empty-directory
    yo aspnetcore-spa
    

    complete instructions could be found here: http://blog.stevensanderson.com/2016/05/02/angular2-react-knockout-apps-on-aspnet-core/

    Hope this helps the next guy searching around on how to get started with SPA using ASP.Net 5 and those libraries.