Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single Page Application Project Templates for.NET 4.5 and Angular

Has there ever been a more confusing/difficult time to be a web developer using the Microsoft stack? That's not really my question... I know that the answer is a categorical no. :)

The single page app template that comes with VS 2013 is deplorable.

I've been working on building up a similar project template that uses Angular JS on the client, but I'm starting to spin my wheels a bit porting over the external (openId/oauth) login features.

I believe this is because of the lack of good, single-point-of-truth, and current documentation for Katana's auth/security bits and also because of how unreadable the client side code is in the S.P.A. template in visual studio 2013.

I know that I can get through it, but while I'm struggling with it, I'm wondering:

Are there any good community provided project templates or example code bases in existence that use .NET 4.5 (MVC5/Web Api 2), Angular JS, the new ASP.NET Identity stuff, and the Katana packages?

There's HotTowel.Angular, but it takes no stance on security. Besides, it's a Nuget package, which can't or shouldn't dictate as much as a proper project template can.

like image 251
Ronnie Overby Avatar asked Mar 01 '14 21:03

Ronnie Overby


People also ask

What single page application templates does Visual Studio include?

Currently, Visual Studio includes ASP.NET Core Single Page Application (SPA) templates that support Angular and React. The templates provide a built in Client App folder in your ASP.NET Core projects that contains the base files and folders of each framework.

How do I create a standalone angular template?

In the New Project Dialog, select Create a new project. Search for Angular in the search bar at the top and then select Standalone Angular Template. Give your project and solution a name. When you get to the Additional information window, be sure to check the Add integration for Empty ASP.NET Web API Project option.

What is a single-page application?

A web application that is composed of one web page and handles the request for other pages through AJAX and automatically replaces the view with the new page response. As a result of this, the single-page applications are very responsive with improved speed.

How to create a single page application using AngularJS routing?

We are using AngularJS routing to create the Single Page Application by ASP.NET static file serving. We need to point a static page to get all the requests, then Angular will handle the request and decide which page to serve. Let’s create HTML page in a wwwroot folder.


1 Answers

I agree with your observations. I have found the following setup that seems to meet your requirements and I think works very well (I don't have a template), I would suggest the following:

  1. Create an empty WebApi2 project and adopt authentication/authorization depicted here
  2. Use a regular index.html in the base directory as a launching point for your angular application. You can either maintain your client packages with nuget, npm, or bower.
  3. Use whatever technique you like for organization of client code.

Personally, I would create 3 projects, One for client code, (mydomain.com) One for your api (api.mydomain.com) and one for your Model/Repository/Data Access layer.

update Here is an open-source project that might be what you're looking for!

like image 107
calebboyd Avatar answered Oct 13 '22 19:10

calebboyd