• Stars
    star
    488
  • Rank 90,182 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Template for ASP.NET Core, Angular with Webpack and Visual Studio

Angular Visual Studio Webpack Starter

Build status

Template for Webpack, Visual Studio, ASP.NET Core and Angular. Both the client and the server side of the application are implemented inside one ASP.NET Core project which makes it easier to deploy.

vs_webpack_angular2

Features

Authors

Fabian GosebrinkDamien BowdenRoberto Simonetti

Fabian Gosebrink, Damien Bowden, Roberto Simonetti

Blogs:

Table of contents

Project structure

  • src
    • AngularWebpackVisualStudio ASP.NET Core Web API project
      • .template.config Folder containing the template information about the dotnet new template
      • wwwroot Root for Angular application deployment
      • angularApp Angular application
        • main.ts Entry point for JiT compilation
        • main-aot.ts Entry point for AoT compilation
        • tests Client tests
      • config Folder for configuration files
        • webpack.dev.js webpack configuration file for development
        • webpack.prod.js webpack configuration file for production
        • webpack.test.js webpack configuration file for testing
        • spec.bundle.js Used for client testing
      • Controllers Folder for API controllers
      • Models Folder for models
      • Startup.cs Web API configuration
      • package.json Packages for Angular app
      • karma.conf.js Karma configuration for client testing
      • tsconfig.json & tsconfig-aot.json TypeScript & ngc compiler options
      • webpack.config.js Webpack configuration file for development & production of Angular app
  • tests
    • AngularWebpackVisualStudio_Tests API tests

Installing

Requirements:

Yarn

You can use this template also with yarn.

Visual Studio

The installed nodejs on your system needs to be used inside Visual Studio and not the nodejs from Visual Studio. You need to set the path of your node before the VS node.

In Visual Studio: Tools -> Options -> Projects and Solutions -> Web Package Management -> External Web Tools

Move the $(Path) option above the Visual Studio one.

NPM Task Runner

The NPM Task Runner can be used to build the client application from inside Visual Studio. This task runner can be downloaded from:

https://marketplace.visualstudio.com/items?itemName=MadsKristensen.NPMTaskRunner

Running

The ASP.NET Core application contains both the server side API services and also hosts the Angular client application. The source code for the Angular application is implemented in the angularApp folder. Webpack is then used to deploy the application, using the development build or a production build, which deploys the application to the wwwroot folder. This makes it easy to deploy the application using the standard tools from Visual Studio with the standard configurations.

Commands

The npm scripts are used to build, watch the client application as required. The scripts can be run from the command line or the NPM Task Runner.

The watch-webpack-dev npm script automatically starts in Visual Studio because it has been added to the package.json:

"-vs-binding": { "ProjectOpened": [ "watch-webpack-dev" ] }

All available commands are the following:

"start": "concurrently \"webpack-dev-server --env=dev --open --hot --inline --port 8080\" \"dotnet run\" ",
"webpack-dev": "webpack --env=dev",
"webpack-production": "webpack --env=prod",
"build-dev": "npm run webpack-dev",
"build-production": "npm run webpack-production",
"watch-webpack-dev": "webpack --env=dev --watch --color",
"watch-webpack-production": "npm run build-production --watch --color",
"publish-for-iis": "npm run build-production && dotnet publish -c Release",
"test": "karma start",
"test-ci": "karma start --single-run --browsers ChromeHeadless",
"lint": "tslint ./angularApp"

Development

For the Angular app, we use JiT compilation.

npm run build-dev

Watch for development

npm run watch-webpack-dev

Hot Module Replacement

npm start

Production

For the Angular app, we use AoT compilation, tree shaking & minification.

npm run webpack-production

Testing

The xUnit test for ASP.NET Core API is in tests/AngularWebpackVisualStudio_Tests folder:

dotnet test

or from Visual Studio: Test -> Run -> All Tests

See this link for more details on xUnit testing in ASP.NET Core: https://docs.microsoft.com/it-it/dotnet/articles/core/testing/unit-testing-with-dotnet-test

The Angular test is in angularApp/tests folder. It uses Karma test runner and Jasmine test framework:

npm test

runs the tests and watches for development. If you want to run the tests with a headless browser only one single time just type

npm run test-ci

See this link for more details on Angular testing: https://angular.io/guide/testing

Dotnet Template

To install a template for this package we prepared a template.json to do that.

Just run dotnet new --install <PATH> where is the path to the folder where the .template.config folder lives.

After that you should see the template when running dotnet new on commandline

dotnetnew

Now you can use the temaplte with dotnet new angularwebapi

Notes

The Webpack configuration could also build all of the scss and css files to a separate app.css or app."hash".css which could be loaded as a single file in the distribution. Some of the vendor js and css could also be loaded directly in the html header using the index.html file and not included in the Webpack build.

Links

License

MIT

More Repositories

1

angular-auth-oidc-client

npm package for OpenID Connect, OAuth Code Flow with PKCE, Refresh tokens, Implicit Flow
TypeScript
988
star
2

AspNet6IdentityServer4AngularOidcFlows

OpenID Connect Code Flow PKCE / Implicit Flow with Angular and ASP.NET Core 6 IdentityServer4
TypeScript
725
star
3

IdentityServer4AspNetCoreIdentityTemplate

An ASP.NET Core 6.0 IdentityServer4 Identity Bootstrap 4 template with localization
C#
326
star
4

AspNetCoreLocalization

Localization.SqlLocalizer & ASP.NET Core MVC Localization Examples
C#
250
star
5

AspNetCoreHybridFlowWithApi

Different ASP.NET Core applications using OpenID Connect Hybrid flow Code Flow, Code Flow with PKCE, JWT APIs, MFA examples
C#
247
star
6

AspNetCoreCertificates

Certificate Manager in .NET Core for creating and using X509 certificates
C#
227
star
7

AspNetCoreMultipleProject

ASP.NET Core API EF Core and Swagger
C#
227
star
8

AspNetCoreOpeniddict

OpenIddict with Angular and Blazor WASM BFF OpenID Connect Code Flow with PKCE clients and ASP.NET Core APIs
C#
224
star
9

AspNetCoreAngularSignalRSecurity

Security with ASP.NET Core, SignalR and Angular
C#
214
star
10

AspNetCoreAngularSignalR

SignalR ASP.NET Core Angular
TypeScript
186
star
11

ElasticsearchCRUD

Elasticsearch .NET netstandard API
C#
172
star
12

IdentityServer4VueJs

IdentityServer4 Vue.js oidc-client-js OpenID Connect code flow with PKCE
C#
124
star
13

AspNetCoreWindowsAuth

Local and Windows Authentication, ASP.NET Core MVC, IdentityServer4
C#
118
star
14

AspNetCoreIdentityFido2Mfa

ASP.NET Core 7 Identity with FIDO2 WebAuthn MFA, passwordless
CSS
118
star
15

AspNetCoreFileUploadFileTable

ASP.NET Core MVC file upload / download with MS SQL Server FileTable
C#
114
star
16

AspNetCoreServiceBus

ASP.NET Core with Azure Service Bus
C#
101
star
17

Secure_gRpc

Security Experiments with gRPC and ASP.NET Core 5
C#
92
star
18

aspnetcore-standup-authn-authz

https://www.youtube.com/watch?v=eQ7eLOA69T0
84
star
19

Blazor.BFF.OpenIDConnect.Template

Blazor.BFF.OpenIDConnect.Template, Blazor WASM hosted in ASP.NET Core using OpenID Connect BFF (server authentication)
CSS
80
star
20

AspNetCoreCsvImportExport

ASP.NET Core CSV import export custom formatters
C#
78
star
21

SendingEncryptedData

.NET Core Encryption
CSS
74
star
22

AspNetCoreID4External

external OpenID Connect Login to IdentityServer and ASP.NET Core with AAD
C#
72
star
23

AspNetCoreMvcVueJs

ASP.NET Core with Vue.js
C#
69
star
24

aspnetcore-standup-securing-apis

ASP.NET Core Community Standup Securing APIs
66
star
25

AspNetCoreNlog

ASP.NET Core NLog MS SQL Server PostgreSQL MySQL Elasticsearch
C#
59
star
26

AzureADAuthRazorUiServiceApiCertificate

Azure AD flows using ASP.NET Core and Microsoft.Identity
CSS
58
star
27

AspNetCoreMvcAngular

ASP.NET Core MVC with angular in MVC View OpenID Connect Hybrid Flow
C#
55
star
28

AspNetCoreOData

ASP.NET Core OData
C#
53
star
29

AspNetCoreIdentityServer4ResourceOwnerPassword

ASP.NET Core IdentityServer4 Resource Owner Flow Refresh token and custom user repository
CSS
51
star
30

AspNetCoreCertificateAuth

ASP.NET Core 3.1 Certificate Authentication Self Signed and Chained
C#
50
star
31

Blazor.BFF.AzureB2C.Template

Blazor.BFF.AzureB2C.Template, Blazor WASM hosted in ASP.NET Core using Azure B2C BFF (server authentication) and Microsoft Graph
CSS
47
star
32

AspNetCoreExperiments

ASP.NET Core Blazor BFF with Azure AD and Razor page
CSS
46
star
33

Blazor.BFF.AzureAD.Template

Blazor.BFF.AzureAD.Template, Blazor WASM hosted in ASP.NET Core using Azure AD BFF (server authentication)
CSS
45
star
34

ApiJwtWithTwoSts

Web API authorization, multi-IDP solutions in ASP.NET Core
C#
44
star
35

AspNetCoreElasticsearchNestAuditTrail

ASP.NET Core Elasticsearch Nest Audit Trial
C#
44
star
36

AzureAD-Auth-MyUI-with-MyAPI

Azure AD Auth with ASP.NET CORE UI and ASP.ENT Core API
PowerShell
42
star
37

SignalRMessagingErrorHandling

SignalR Messaging with Error Handling
C#
40
star
38

AspNetCoreMvcProtobufFormatters

ASP.NET Core MVC Protobuf Formatters (InputFormatter and OutputFormatter)
C#
38
star
39

WebApiFileUpload

Web API File Upload
C#
38
star
40

AspNet5GeoElasticsearch

ASP.NET Core MVC Geo Elasticsearch Swashbuckle Swagger
C#
37
star
41

AspNetCorePagesWebpack

ASP.NET Core Razor Pages Bootstrap 4 Application using Webpack, Typescript, and npm
C#
37
star
42

AspNetCoreFilters

ASP.NET Core MVC Filters
C#
34
star
43

AspNetCoreSQLite

ASP.NET Core 2.0 MVC SQLite Entity Framework Core
JavaScript
34
star
44

dotnet-template-angular

oidc azure-ad angular dotnet-template openid
TypeScript
34
star
45

AspNetCoreMvcSharedLocalization

ASP.NET Core MVC shared localization
C#
33
star
46

AspNetCoreApiAuthMultiIdentityProvider

ASP.NET Core Api Auth with multiple Identity Providers
C#
32
star
47

AspNetCoreQuartz

ASP.NET Core scheduling with Quartz.NET and SignalR
JavaScript
31
star
48

AspNetCoreYarp

ASP.NET Core & Yarp reverse proxy with Azure AD OIDC, OAuth2
C#
31
star
49

AngularLocalizationAspNetCore

Angular ASP.NET Core localization
C#
26
star
50

AngularAutoSaveCommands

ASP.NET Core, Angular, Angular CLI, MS SQL Server, Undo, Redo, Auto save
C#
24
star
51

AzureFunctionsSecurity

Azure Functions Security
C#
24
star
52

angular-auth-oidc-sample-google-openid

Angular oidc client with google Identity OpenID
JavaScript
23
star
53

Angular2AutoCompleteAspNetCoreElasticsearch

Angular autocomplete, ASP.NET Core, Elasticsearch
C#
23
star
54

SignalRMessaging

JavaScript
22
star
55

AspNetCoreIdentityServer4Angular2Docker

C#
22
star
56

AspNetCorePostgreSQLDocker

ASP.NET Core Docker EF Core
C#
22
star
57

AspNetCoreIdentityServer4Persistence

EF Core database for the IdentityServer4 configuration data
C#
22
star
58

azureb2c-fed-azuread

Securing ASP.NET Core Razor Pages, Web APIs with Azure B2C external and Azure AD internal identities
C#
22
star
59

AspNet5Watcher

ASP.NET Core MVC 6 Elasticsearch watcher SignalR example
JavaScript
21
star
60

SeparatingApisPerSecurityLevel

Auth0, ASP.NET Core OAuth, OIDC
C#
21
star
61

AnimalMarketEnginsSqliteDb

ASP.NET Web API with SQLite
C#
20
star
62

WebAPIODataV4

C#
19
star
63

TeamsAdminUI

ASP.NET Core Razor Page app using Graph API to create team meetings, send emails
C#
18
star
64

AspNetCoreBackChannelLogout

ASP.NET Core Back-Channel Logout for Hybrid Clients, Redis, Key Vault, Azure
C#
18
star
65

Auth0AngularAspNetCoreApi

Auth0 with Angular and an ASP.NET Core API
TypeScript
17
star
66

AspNetCoreMicrosoftGraph

ASP.NET Core application and API using Microsoft Graph delegated clients
C#
15
star
67

AspNetCoreBlazorMicrosoftGraph

ASP.NET Core Blazor with Microsoft Graph
CSS
15
star
68

WebAPILocalization

C#
14
star
69

WebApi2AttributeFilters

C#
14
star
70

AngularComponentPlotly

Angular Component for Plotly, ASP.NET Core, Elasticsearch
TypeScript
14
star
71

PwaBlazorBffAzureB2C

Azure B2C Blazor BFF ASP.NET Core hosted with support for PWA
CSS
13
star
72

AspNetCoreBootstrap4Validation

ASP.NET Core MVC Bootstrap 4 Ajax
CSS
13
star
73

AspNetCoreTenantSelect

Switch tenants in an ASP.NET Core app using Azure AD with multi tenants
C#
12
star
74

AspNetCoreAzureSearch

ASP.NET Core with Azure Cognitive Search
C#
12
star
75

AspNet5SearchWithElasticsearchCrud

ASP.NET Core MVC Elasticsearch dnxcore50
C#
12
star
76

WebSearchWithElasticsearchEntityFrameworkAsPrimary

JavaScript
12
star
77

WebSearchWithElasticsearch

CSS
12
star
78

SharedAspNetCore

demo sharing controller and Razor Pages in a shared aseembly, project
C#
12
star
79

AspNetCoreAzureAdAzureStorage

ASP.NET Core Razor page with uses Azure Storage to upload download files securely using OAuth and Open ID Connect
C#
12
star
80

ElasticsearchBulkInsert

C#
11
star
81

DataTransferSQLWithEntityFrameworkToElasticsearch

C#
11
star
82

WebApiFileUploadFileTable

C#
11
star
83

SQLiteExamples

C#
11
star
84

WiXPowerShellExample

C#
11
star
85

PoCWindowsAuth

Securing an ASP.NET Core app and web API using windows authentication
CSS
11
star
86

AspNetCoreHangfire

ASP.NET Core with Hangfire
TSQL
11
star
87

AspNetCoreWebApiContribProtobufSample

ASP.NET Core Protobuf API Formatters
C#
10
star
88

AspNetCoreAzureADCAE

Azure AD Continuous Access in an ASP.NET Core Razor Page, Blazor app using a Web API
C#
10
star
89

AzureDurableFunctions

Using External Inputs in Azure Durable functions
C#
10
star
90

EmailCalandarsClient

Send emails with Microsoft Graph API from a Desktop APP, C# and Visual basic projects
C#
9
star
91

WebAppGeoElasticsearch

MVC google maps search using Elasticsearch
JavaScript
8
star
92

ElasticsearchParentChildGrandChild

Console app demo for Elasticsearch Parent Child GrandChild routing
C#
8
star
93

SignalRHostWithUnity

C#
8
star
94

AspNetCoreIISDeployment

Demo project used for ASP.NET Core IIS deployment
C#
8
star
95

AspNetCoreVS2017Docker

ASP.NET Core Docker VS2017
C#
8
star
96

AspNet5AngularJSDynamicRoutes

ASP.NET Core Angular-UI-Router example
JavaScript
8
star
97

WebApiCSVExportFromElasticsearch

C#
8
star
98

WebApiParameters

C#
8
star
99

OnBehalfFlowOidcDownstreamApi

This demo shows how to implement the On Behalf Of flow between an Azure AD protected API and an API protected using OpenIddict.
C#
8
star
100

MvcDynamicDropdownList

aspnet-core mvc razor javascript
C#
8
star