• Stars
    star
    505
  • Rank 87,373 (Top 2 %)
  • Language
    JavaScript
  • Created about 10 years ago
  • Updated 6 months ago

Reviews

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

Repository Details

West Wind Album Viewer ASP.NET Core and Angular Sample

West Wind Album Viewer ASP.NET Core Sample

Sample Angular application demonstrating ASP.NET Core API features

This is a sample ASP.NET Core application that demonstrates basic features of ASP.NET Core in an API backend application with an Angular frontend. The application allows browsing and editing of a list of albums and artists interactively.

On the Desktop:

In a Mobile Web Browser:

Online Sample:

ASP.NET Core Features

The ASP.NET Core Backend demonstrates:

  • Creating an API backend service
  • Isolating business logic and Controller code
  • Using a base Repository for business logic
  • Separating code into separate projects
  • Custom User Authentication
  • CORS Support
  • Using ASP.NET Core as a backend to an Angular 2.0 front end

The sample also includes a few Server Side Rendered MVC pages for browsing and viewing of albums and artists. I'll be adding the edit pages at a later point.

Version supported:

  • .NET Core 6.0
  • 6.0 SDK or later
  • Visual Studio 2022 or later

Angular Features

The Angular front end application demonstrates:

  • Page based Application
  • Mobile friendly, adaptive UI
  • Routing
  • Animations and Page Transitions
  • Client side and server side Authentication tracking
  • Client side and server side Validation
  • Managing Server Urls (dev/production)
  • Angular CLI Project

Version supported:

  • Angular 11.1.1
  • Angular CLI 11.1

Getting Started

To check out the application you can:

  • Run the Docker Image
  • Run everything local

.NET Core API Configuration

You should just be able to clone this repo as is on either Windows or Mac (and probably Linux) and do:

cd <Base Solution Folder>
dotnet restore
cd .\src\AlbumViewerNetCore
dotnet run

Then navigate to http://localhost:5000 to start the application. First launch might fail due a timeout due to the initial DB creation, but subsequent requests should work.

If you're running the application locally through IIS or Kestrel, the application should just work as is. By default it uses a SqLite data base that is created in the Web app's content (not Web) root.

The sample also works with SQL Server but you have to create the database for that to work and set the connection string in appsettings.json.

To switch between SqLite and Sql Server use the useSqlLite configuration settings:

  "Data": {
    "AlbumViewer": {
      "useSqLite": "true",
      "SqlServerConnectionString": "server=.;database=AlbumViewer;integrated security=true;",
    } 
  },
  //... other settings omitted
}

In either case initial albums/artist data should auto-create the first time the app is run.

Using SqLite

SqLite will automatically create the database file in the content content root of the project (same folder as project.json). For this to work make sure that the account the Web application is running under has appropriate rights to create a new file and read/write to that file in the content folder.

Using Sql Server

To use Sql Server create a new empty database and then point the connection string at the new database. Make sure the account the Web server is running under has rights to create tables and then read/write data.

In appsettings.json (or other configuration settings) set Data.useSqLite: false and set the Data.SqlServerConnectionString to a valid connection string to your database.

{
    "Data": {
        "useSqLite": "false",
        "SqlServerConnectionString": "server=.;database=AlbumViewer;integrated security=true;MultipleActiveResultSets=true;App=AlbumViewer"
    },
    ...

To develop the AlbumViewer Angular example

The Angular front end sits in a separate AlbumViewerAngular project folder and is built separately from the ASP.NET Core application.

The sample however, does ship with pre-compiled .js files for the sample that have been copied into the Web project's wwwroot folder so the application will just run through IIS Express/IIS or Kestrel.

Making changes to the Angular application requires transpiling of the typescript source files. In order to make changes to the Angular 2 client sample run the following from a command window:

cd <installFolder>\src\AlbumViewerAngular
npm install
ng serve

then navigate to http://localhost:4200 to run the application. Note this uses the WebPack development server rather than running through IIS Express or Kestrel for the front end assets - index.html, all css, images etc. are served from the development server and only API requests go through Kestrel/IIS.

Depending on which port you run the ASP.NET Core application you may have to change the API server base URL which defaults to http://localhost:5000/ in the app/business/appConfiguration.ts file. The default is when running the development server that requests are routed to http://localhost:5000/ which is where Kestrel runs by default.

Once you've made your changes, you need to build the application's final output which builds into the API applications wwwroot folder.

Run:

ng build --prod

which creates the final transpiled bundles you can use to run through the ASP.NET Core application on http://localhost:5000/.

I've changed the default output folder in angular-cli.json from the .\dist folder to the ASP.NET Core app's wwwroot folder so that the application can run entirely served by Kestrel or IIS. It also still works using ng serve which uses whatever path is used in angular-cli.json.

Run in Docker

If you just want to run the application from a docker file, you can use the following from a command line if Docker is installed:

docker pull rickstrahl/albumviewer
docker run  -it -p 5004:80 --name albumviewer  rickstrahl/albumviewer

You should then be able to navigate to:

http://localhost:5004

to run the application.

To later stop the container:

# docker stop albumviewer

or to restart:

docker start albumviewer -i

This runs a fixed container that was build with dockerbuild.ps1 or dockerbuild.sh. You can update the application and create a new container using these files.

Platforms

Currently the app has been tested to run under Windows and Mac and under Docker running Linux.

License:
This sample is licensed under MIT license. Use, play with, integrate code from this repository as you see fit at your own risk. I try to update this code regularly to reflect the latest current builds of ASP.NET Core and Angular.

Warranty Disclaimer: No Warranty!

IN NO EVENT SHALL THE AUTHOR, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THIS PROGRAM AND DOCUMENTATION, BE LIABLE FOR ANY COMMERCIAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR LOSSES SUSTAINED BY THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS, EVEN IF YOU OR OTHER PARTIES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

More Repositories

1

MarkdownMonster

An extensible Markdown Editor, Viewer and Weblog Publisher for Windows
HTML
1,584
star
2

Westwind.Globalization

Database driven resource localization for .NET applications
C#
543
star
3

Westwind.AspnetCore.LiveReload

ASP.NET Core Live Reload Middleware that monitors file changes in your project and automatically reloads the browser's active page
C#
470
star
4

WestWindWebSurge

Quick and easy URL and Load Testing for your Web applications on Windows
388
star
5

WestwindToolkit

A utility toolkit for .NET development from Core to Web
C#
273
star
6

Westwind.Utilities

A general purpose utility and helper library for .NET development
C#
255
star
7

Westwind.AspNetCore.Markdown

An ASP.NET Core Markdown support library that provides Markdown parsing, a Markdown TagHelper and Markdown Page Handler Middleware
C#
248
star
8

jquery-resizable

A small jQuery plug-in to make DOM components resizable
PowerShell
234
star
9

Westwind.Scripting

Small C# library to provide dynamic runtime code compilation from source code for code and expressions execution
C#
205
star
10

Westwind.ApplicationConfiguration

Strongly typed, code-first configuration classes for .NET applications
C#
178
star
11

Westwind.RazorHosting

Hosting the Razor Runtime outside of ASP.NET/MVC for use in non-Web .NET applications.
C#
144
star
12

jquery-watch

A jQuery plug-in to watch CSS style and attribute changes and get notified when a change occurs
JavaScript
133
star
13

SetResolution

Quickly set Windows Display Resolution via Command Line
C#
128
star
14

Westwind.AspNetCore

ASP.NET Core Helpers and Utilities
C#
126
star
15

Expando

Extensible dynamic types for .NET
C#
108
star
16

LiveReloadServer

A self-contained, local, cross-platform, static file Web Server based on .NET with automatic Live Reloading, Markdown rendering and loose Razor Pages support.
CSS
100
star
17

json.date-extensions

Date parsing extensions for the JavaScript JSON parser to provide real dates from JSON.parse()
JavaScript
93
star
18

wwDotnetBridge

.NET Interop for Visual FoxPro made easy
C#
73
star
19

AspNetWebApiArticle

Source code for ASP.NET WebApi Article for Code Magazine
JavaScript
66
star
20

DeleteFiles

Windows Console Utility to delete files and folders recursively with optional date filtering
C#
62
star
21

CodePaste.NET

CodePaste.NET site code
JavaScript
58
star
22

highlightjs-badge

Addon component to highlightjs that lets you copy code snippets to the clipboard and displays the active syntax
CSS
46
star
23

HtmlSanitizer

A base Html Sanitizer for .NET
C#
35
star
24

Westwind.HtmlPackager

A small utility class used to package HTML content into a self contained HTML document both as a single file, or a folder with all dependencies copied to local.
C#
35
star
25

AspNetFrameworksPerformance

ASP.NET Raw Throughput Performance Post Sample
C#
31
star
26

AspNetCoreRawRequestSample

Sample code for Accepting Raw Request Body in Asp.NET Core Applications
C#
31
star
27

CordovaAlbumViewer

Sample code for "Taming Mobile Apps with Cordova and Visual Studio" CODE magazine article
JavaScript
30
star
28

Westwind.plUploadHandler

An ASP.NET base HttpHandler library to handle plUpload content on the server.
JavaScript
28
star
29

wwMongoDb

Access MongoDb from Visual FoxPro
xBase
25
star
30

WestWind.WebView.HtmlToPdf

Creating Pdf output from Html with .NET on Windows using the WebView2 control
HTML
25
star
31

Westwind.Wpf.Statusbar

A small WPF library to provide animated status bar operations
C#
24
star
32

VisualStudioSnippetConverter

Utility to convert Visual Studio Code Snippets to VS Code and Rider.
C#
22
star
33

vue-mover

A 2 list mover component implemented as a VueJs Component
JavaScript
19
star
34

Westwind.Web.Markdown

Markdown support for ASP.NET WebForms and MVC applications
C#
19
star
35

DotnetDesktopRuntimeInstaller

A tiny Windows console executable that can be distributed with an application and called from an installer to download and install the .NET runtime.
C#
18
star
36

GistIntegration-MarkdownMonster-Addin

Markdown Monster addin to create embeddable Gists for Markdown documents, and to load and save documents from Gists.
C#
17
star
37

Westwind.QueueMessageManager

.NET Library to provide a simple, two-way messaging queue for enabling offloading of long running operations to other processes/machines.
JavaScript
16
star
38

Westwind.WebView

A .NET support library for the `Microsoft.Web.WebView2` control to aid with common operations and .NET / JavaScript interop.
HTML
14
star
39

AspNetCoreFromScratchSample

Working example to experiment with building Asp.net core from scratch
C#
14
star
40

SignalrChatSample

Sample SignalR Chat application that demonstrates VueJs, Angular, FoxPro and .NET clients to SignalR
JavaScript
12
star
41

Westwind.AspNetCore.HostedWebServer

Sample that demonstrates how to create a minmal ASP.NET Web Server that can be hosted in a desktop (or other non-Web) application easily.
C#
12
star
42

Westwind.Data.EfCore

Lightweight Business Object wrapper for Entity framework that handles CRUD operations and error handling.
C#
12
star
43

BlogPosts

HTML
11
star
44

MarkdownMonsterAddinsRegistry

Markdown Monster Addin Registry
10
star
45

Pandoc-MarkdownMonster-Addin

A Pandoc Markdown Parser and Pandoc Operations Library for Markdown Monster
C#
10
star
46

Commander-MarkdownMonster-Addin

Commander C# Scripting Addin that can be used to automate simple tasks in Markdown Monster without creating an Addin. Launch external tools, update documents or mail merge content into the editor.
C#
10
star
47

WpfWebView2Playground

JavaScript
9
star
48

DI2017-AspNet-Core-Angular

Session Materials for Dev Intersection ASP.NET Core and Angular Session
TypeScript
9
star
49

CodeMagazine-DotnetTools

Code Magazine Article Materials for Dotnet Tools Article
C#
8
star
50

VirtualFoxFest2021-FoxProRest

JavaScript
8
star
51

SaveToAzureBlob-MarkdownMonster-Addin

Markdown Monster Addin to open or paste images from your local machine and save them in Azure Blob Storage and embed link into your post.
C#
8
star
52

anti-trust-guilty-album

Anti-Trust Guilty Album - Punk Rock Music
JavaScript
7
star
53

Westwind.Webstore

West Wind Web Store Sample application
JavaScript
7
star
54

HelpBuilderReleases

West Wind Html Help Builder Releases and Bug Reporting
6
star
55

MarkdownMonsterReleases

6
star
56

Snippets-MarkdownMonster-Addin

A Snippet Expansion Manager for embedding templated text into Markdown Monster Markdown documents
C#
6
star
57

West-Wind-Message-Board

West Wind Message Board Web Connection (FoxPro) Sample Application
JavaScript
6
star
58

AspetCoreIISInprocessHostingSample

Simple test project optimized for Hello World style controller ops for comparison of hosting options on Windows
C#
5
star
59

DI2017-ASP.NET-Core-Localization

Session materials for DevIntersection 2017 - ASP.NET Core Localization
JavaScript
5
star
60

Padnug-2016-Angular-AspNet

Sample application and Slides from Rick's May 2nd, 2016 Angular ASP.NET Core Presentation
TypeScript
5
star
61

Console-MarkdownMonster-Addin

A simple Console/Terminal addin for Markdown Monster that displays a terminal window attached to the main Markdown Monster Window
C#
5
star
62

Westwind.Ai

Sample project that demonstrates OpenAI Image Generation
C#
5
star
63

datepicker-native

JavaScript and Vue helper components to make it easier to bind dates to the input/date control and a date button picker.
JavaScript
5
star
64

Westwind.AI

C#
4
star
65

Blazor_Playground

Blazor Sample Application
C#
4
star
66

WestwindWebSurgeReleases

Repository that holds releases for West Wind WebSurge
4
star
67

GithubRespositoryParser

C# Github Repository and Content Retrieval Examples using regular and GraphQL APIs.
C#
3
star
68

MarkdownMonsterAddinProjectTemplate

A Visual Studio Project Template for creating a Markdown Monster Addin
C#
3
star
69

Base64

C#
3
star
70

QfxToQboConverter

A small utility to fix up Quicken QIF files (.qfx) so they can be opened as QBO in Quickbooks.
C#
3
star
71

VirtualFoxFest2022-FoxProDotnet

Session Notes and Samples for Virtual FoxFest FoxPro .NET Interop Session
xBase
3
star
72

Live-Writer-SnagIt-Screen-Capture-Plugin

A Live Writer plug-in to provide screen capturing using TechSmith's SnagIt
C#
3
star
73

SWFOX2019_Vue

JavaScript
3
star
74

SWFOX18_WebConnectionSecurity

2
star
75

samples.west-wind.com

West Wind Samples Web Site
HTML
2
star
76

ChromiumPreview-MarkdownMonster-Addin

A Chromium Preview Browser Addin for the Markdown Monster Markdown Editor
C#
2
star
77

Westwind.Weblog

Source for Westwind Weblog
C#
2
star
78

KavaDocs-MarkdownMonster-Addin

KavaDocs Integration for Markdown Monster
C#
2
star
79

EmptyWebContentProjectTemplate

Empty Content Web Site Project that publishes from the root folder and works optionally with WebDeploy
HTML
2
star
80

SWFOX2019_DotnetCore

JavaScript
2
star
81

CODE.Framework.Core.ServiceHandler

C#
1
star
82

MarkdownMonsterDocumentation

JavaScript
1
star
83

swfox2024-wwdotnetbridge-revisited

Samples, Session Notes and Slides for Southwest Fox 2024 Sessions
HTML
1
star
84

dotnet-tools-padnug2020

1
star
85

WebSurgeDocumentation

Documentation for West Wind WebSurge
JavaScript
1
star
86

WebConnection-WebDemo

Web Connection Sample Application for the Getting Started Walk Through
JavaScript
1
star
87

HighPerformanceAspNet

C#
1
star
88

SWFOX2019_WebConnectionDeployment

PowerShell
1
star
89

SWFOX2018_MarkdownWithFoxPro

JavaScript
1
star