├── .gitignore ├── LICENSE ├── Labs ├── 1. Introduction to the .NET Core SDK.md ├── 2. MVC Applications with ASP.NET Core.md ├── 3. Startup, Hosting and Middleware.md ├── 4. Dependency Injection & Unit Testing.md ├── 4.5 Building Middleware.md ├── 5. Logging and Diagnostics.md ├── 6. Working with Razor Tag Helpers.md ├── 7. Single Page Applications.md ├── 7.5 App building - Attendee List.md ├── 8. APIs with MVC Core.md ├── 8.1 Hosting & Deployment.md ├── Code │ ├── App │ │ ├── AttendeeList.sln │ │ └── AttendeeList │ │ │ ├── .vscode │ │ │ ├── launch.json │ │ │ └── tasks.json │ │ │ ├── AttendeeList.csproj │ │ │ ├── Controllers │ │ │ ├── AttendeesApiController.cs │ │ │ ├── AttendeesController.cs │ │ │ └── PlatformController.cs │ │ │ ├── Formatters │ │ │ └── VCardFormatter.cs │ │ │ ├── Models │ │ │ ├── Attendee.cs │ │ │ └── WorkshopContext.cs │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ └── launchSettings.json │ │ │ ├── Startup.cs │ │ │ ├── Views │ │ │ ├── Attendees │ │ │ │ ├── Create.cshtml │ │ │ │ ├── Delete.cshtml │ │ │ │ ├── Details.cshtml │ │ │ │ ├── Edit.cshtml │ │ │ │ └── Index.cshtml │ │ │ └── _ViewImports.cshtml │ │ │ ├── appsettings.json │ │ │ └── wwwroot │ │ │ └── lib │ │ │ ├── bootstrap │ │ │ ├── .bower.json │ │ │ ├── LICENSE │ │ │ └── dist │ │ │ │ ├── css │ │ │ │ ├── bootstrap-theme.css │ │ │ │ ├── bootstrap-theme.css.map │ │ │ │ ├── bootstrap-theme.min.css │ │ │ │ ├── bootstrap-theme.min.css.map │ │ │ │ ├── bootstrap.css │ │ │ │ ├── bootstrap.css.map │ │ │ │ ├── bootstrap.min.css │ │ │ │ └── bootstrap.min.css.map │ │ │ │ ├── fonts │ │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ │ └── glyphicons-halflings-regular.woff2 │ │ │ │ └── js │ │ │ │ ├── bootstrap.js │ │ │ │ ├── bootstrap.min.js │ │ │ │ └── npm.js │ │ │ ├── jquery-validation-unobtrusive │ │ │ ├── .bower.json │ │ │ ├── jquery.validate.unobtrusive.js │ │ │ └── jquery.validate.unobtrusive.min.js │ │ │ ├── jquery-validation │ │ │ ├── .bower.json │ │ │ ├── LICENSE.md │ │ │ └── dist │ │ │ │ ├── additional-methods.js │ │ │ │ ├── additional-methods.min.js │ │ │ │ ├── jquery.validate.js │ │ │ │ └── jquery.validate.min.js │ │ │ └── jquery │ │ │ ├── .bower.json │ │ │ ├── LICENSE.txt │ │ │ └── dist │ │ │ ├── jquery.js │ │ │ ├── jquery.min.js │ │ │ └── jquery.min.map │ ├── Lab1 │ │ └── MyNewApp │ │ │ ├── MyNewApp.csproj │ │ │ └── Program.cs │ ├── Lab2A │ │ ├── Lab2A.sln │ │ └── src │ │ │ └── Lab2A │ │ │ ├── Areas │ │ │ └── Identity │ │ │ │ └── Pages │ │ │ │ └── _ViewStart.cshtml │ │ │ ├── Controllers │ │ │ ├── HomeController.cs │ │ │ └── PeopleController.cs │ │ │ ├── Data │ │ │ ├── ApplicationDbContext.cs │ │ │ └── Migrations │ │ │ │ ├── 00000000000000_CreateIdentitySchema.Designer.cs │ │ │ │ ├── 00000000000000_CreateIdentitySchema.cs │ │ │ │ ├── 20170116070549_Person Class.Designer.cs │ │ │ │ ├── 20170116070549_Person Class.cs │ │ │ │ └── ApplicationDbContextModelSnapshot.cs │ │ │ ├── Lab2A.csproj │ │ │ ├── Models │ │ │ ├── ApplicationUser.cs │ │ │ └── Person.cs │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ └── launchSettings.json │ │ │ ├── Services │ │ │ ├── IEmailSender.cs │ │ │ ├── ISmsSender.cs │ │ │ └── MessageServices.cs │ │ │ ├── Startup.cs │ │ │ ├── Views │ │ │ ├── Home │ │ │ │ ├── About.cshtml │ │ │ │ ├── Contact.cshtml │ │ │ │ └── Index.cshtml │ │ │ ├── People │ │ │ │ ├── Create.cshtml │ │ │ │ ├── Delete.cshtml │ │ │ │ ├── Details.cshtml │ │ │ │ ├── Edit.cshtml │ │ │ │ └── Index.cshtml │ │ │ ├── Shared │ │ │ │ ├── Error.cshtml │ │ │ │ ├── _Layout.cshtml │ │ │ │ ├── _LoginPartial.cshtml │ │ │ │ └── _ValidationScriptsPartial.cshtml │ │ │ ├── _ViewImports.cshtml │ │ │ └── _ViewStart.cshtml │ │ │ ├── appsettings.json │ │ │ ├── bundleconfig.json │ │ │ ├── libman.json │ │ │ └── wwwroot │ │ │ ├── css │ │ │ ├── site.css │ │ │ └── site.min.css │ │ │ ├── favicon.ico │ │ │ ├── images │ │ │ ├── banner1.svg │ │ │ ├── banner2.svg │ │ │ ├── banner3.svg │ │ │ └── banner4.svg │ │ │ ├── js │ │ │ ├── site.js │ │ │ └── site.min.js │ │ │ └── lib │ │ │ ├── bootstrap │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── dist │ │ │ │ ├── css │ │ │ │ │ ├── bootstrap-grid.css │ │ │ │ │ ├── bootstrap-grid.css.map │ │ │ │ │ ├── bootstrap-grid.min.css │ │ │ │ │ ├── bootstrap-grid.min.css.map │ │ │ │ │ ├── bootstrap-reboot.css │ │ │ │ │ ├── bootstrap-reboot.css.map │ │ │ │ │ ├── bootstrap-reboot.min.css │ │ │ │ │ ├── bootstrap-reboot.min.css.map │ │ │ │ │ ├── bootstrap.css │ │ │ │ │ ├── bootstrap.css.map │ │ │ │ │ ├── bootstrap.min.css │ │ │ │ │ └── bootstrap.min.css.map │ │ │ │ └── js │ │ │ │ │ ├── bootstrap.bundle.js │ │ │ │ │ ├── bootstrap.bundle.js.map │ │ │ │ │ ├── bootstrap.bundle.min.js │ │ │ │ │ ├── bootstrap.bundle.min.js.map │ │ │ │ │ ├── bootstrap.js │ │ │ │ │ ├── bootstrap.js.map │ │ │ │ │ ├── bootstrap.min.js │ │ │ │ │ └── bootstrap.min.js.map │ │ │ └── package.json │ │ │ ├── jquery-validation-unobtrusive │ │ │ ├── jquery.validate.unobtrusive.js │ │ │ └── jquery.validate.unobtrusive.min.js │ │ │ ├── jquery-validation │ │ │ ├── LICENSE.md │ │ │ ├── README.md │ │ │ ├── changelog.md │ │ │ ├── dist │ │ │ │ ├── additional-methods.js │ │ │ │ ├── additional-methods.min.js │ │ │ │ ├── jquery.validate.js │ │ │ │ └── jquery.validate.min.js │ │ │ └── package.json │ │ │ └── jquery │ │ │ ├── core.js │ │ │ ├── jquery.js │ │ │ ├── jquery.min.js │ │ │ ├── jquery.min.map │ │ │ ├── jquery.slim.js │ │ │ ├── jquery.slim.min.js │ │ │ └── jquery.slim.min.map │ ├── Lab2B │ │ ├── Lab2B.sln │ │ └── src │ │ │ └── Lab2 │ │ │ ├── Lab2.csproj │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ └── launchSettings.json │ │ │ ├── Startup.cs │ │ │ ├── appsettings.json │ │ │ └── wwwroot │ │ │ └── index.html │ ├── Lab2C │ │ ├── Lab2C.sln │ │ └── src │ │ │ └── Lab2 │ │ │ ├── Controllers │ │ │ └── HomeController.cs │ │ │ ├── Lab2.csproj │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ └── launchSettings.json │ │ │ ├── Startup.cs │ │ │ ├── appsettings.json │ │ │ └── wwwroot │ │ │ └── index.html │ ├── Lab3 │ │ ├── Lab3.sln │ │ └── src │ │ │ └── Lab3 │ │ │ ├── Lab3.csproj │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ └── launchSettings.json │ │ │ ├── Startup.cs │ │ │ ├── appsettings.json │ │ │ └── wwwroot │ │ │ └── index.html │ ├── Lab4A │ │ ├── Lab4A.sln │ │ └── src │ │ │ └── Lab4A │ │ │ ├── Lab4A.csproj │ │ │ ├── Middleware │ │ │ └── RequestIdMiddleware.cs │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ └── launchSettings.json │ │ │ ├── Services │ │ │ └── RequestId.cs │ │ │ └── Startup.cs │ ├── Lab4B │ │ ├── Lab4B.sln │ │ └── src │ │ │ ├── Lab4B.csproj │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ └── launchSettings.json │ │ │ ├── RequestCultureMiddleware.cs │ │ │ ├── RequestCultureOptions.cs │ │ │ ├── Startup.cs │ │ │ ├── appsettings.Development.json │ │ │ ├── appsettings.json │ │ │ └── config.json │ ├── Lab5A │ │ ├── Lab5A.sln │ │ └── src │ │ │ └── Lab5A │ │ │ ├── Lab5A.csproj │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ └── launchSettings.json │ │ │ ├── Startup.cs │ │ │ ├── appsettings.json │ │ │ └── wwwroot │ │ │ └── index.html │ ├── Lab5B │ │ ├── Lab5B.sln │ │ └── src │ │ │ └── Lab5B │ │ │ ├── Lab5B.csproj │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ └── launchSettings.json │ │ │ ├── Startup.cs │ │ │ ├── appsettings.json │ │ │ ├── logfile.txt │ │ │ └── wwwroot │ │ │ └── index.html │ ├── Lab5C │ │ ├── Lab5C.sln │ │ └── src │ │ │ └── Lab5C │ │ │ ├── Lab5C.csproj │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ └── launchSettings.json │ │ │ ├── Startup.cs │ │ │ ├── appsettings.json │ │ │ ├── logfile.txt │ │ │ └── wwwroot │ │ │ └── index.html │ ├── Lab5D │ │ ├── Lab5D.sln │ │ └── src │ │ │ └── Lab5D │ │ │ ├── Lab5D.csproj │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ └── launchSettings.json │ │ │ ├── Startup.cs │ │ │ ├── appsettings.json │ │ │ ├── logfile.txt │ │ │ └── wwwroot │ │ │ └── index.html │ ├── Lab6 │ │ ├── Lab6.sln │ │ └── src │ │ │ └── Lab6 │ │ │ ├── Areas │ │ │ └── Identity │ │ │ │ └── Pages │ │ │ │ └── _ViewStart.cshtml │ │ │ ├── Controllers │ │ │ └── HomeController.cs │ │ │ ├── Data │ │ │ ├── ApplicationDbContext.cs │ │ │ └── Migrations │ │ │ │ ├── 00000000000000_CreateIdentitySchema.Designer.cs │ │ │ │ ├── 00000000000000_CreateIdentitySchema.cs │ │ │ │ └── ApplicationDbContextModelSnapshot.cs │ │ │ ├── Lab6.csproj │ │ │ ├── Models │ │ │ └── ApplicationUser.cs │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ └── launchSettings.json │ │ │ ├── RepeatTagHelper.cs │ │ │ ├── Services │ │ │ ├── IEmailSender.cs │ │ │ ├── ISmsSender.cs │ │ │ └── MessageServices.cs │ │ │ ├── Startup.cs │ │ │ ├── Views │ │ │ ├── Home │ │ │ │ ├── About.cshtml │ │ │ │ ├── Contact.cshtml │ │ │ │ └── Index.cshtml │ │ │ ├── Shared │ │ │ │ ├── Error.cshtml │ │ │ │ ├── _Layout.cshtml │ │ │ │ ├── _LoginPartial.cshtml │ │ │ │ └── _ValidationScriptsPartial.cshtml │ │ │ ├── _ViewImports.cshtml │ │ │ └── _ViewStart.cshtml │ │ │ ├── appsettings.json │ │ │ ├── bundleconfig.json │ │ │ ├── libman.json │ │ │ └── wwwroot │ │ │ ├── css │ │ │ ├── site.css │ │ │ └── site.min.css │ │ │ ├── favicon.ico │ │ │ ├── images │ │ │ ├── banner1.svg │ │ │ ├── banner2.svg │ │ │ ├── banner3.svg │ │ │ └── banner4.svg │ │ │ ├── js │ │ │ ├── site.js │ │ │ └── site.min.js │ │ │ └── lib │ │ │ ├── bootstrap │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── dist │ │ │ │ ├── css │ │ │ │ │ ├── bootstrap-grid.css │ │ │ │ │ ├── bootstrap-grid.css.map │ │ │ │ │ ├── bootstrap-grid.min.css │ │ │ │ │ ├── bootstrap-grid.min.css.map │ │ │ │ │ ├── bootstrap-reboot.css │ │ │ │ │ ├── bootstrap-reboot.css.map │ │ │ │ │ ├── bootstrap-reboot.min.css │ │ │ │ │ ├── bootstrap-reboot.min.css.map │ │ │ │ │ ├── bootstrap.css │ │ │ │ │ ├── bootstrap.css.map │ │ │ │ │ ├── bootstrap.min.css │ │ │ │ │ └── bootstrap.min.css.map │ │ │ │ └── js │ │ │ │ │ ├── bootstrap.bundle.js │ │ │ │ │ ├── bootstrap.bundle.js.map │ │ │ │ │ ├── bootstrap.bundle.min.js │ │ │ │ │ ├── bootstrap.bundle.min.js.map │ │ │ │ │ ├── bootstrap.js │ │ │ │ │ ├── bootstrap.js.map │ │ │ │ │ ├── bootstrap.min.js │ │ │ │ │ └── bootstrap.min.js.map │ │ │ └── package.json │ │ │ ├── jquery-validation-unobtrusive │ │ │ ├── jquery.validate.unobtrusive.js │ │ │ └── jquery.validate.unobtrusive.min.js │ │ │ ├── jquery-validation │ │ │ ├── LICENSE.md │ │ │ ├── README.md │ │ │ ├── changelog.md │ │ │ ├── dist │ │ │ │ ├── additional-methods.js │ │ │ │ ├── additional-methods.min.js │ │ │ │ ├── jquery.validate.js │ │ │ │ └── jquery.validate.min.js │ │ │ └── package.json │ │ │ └── jquery │ │ │ ├── core.js │ │ │ ├── jquery.js │ │ │ ├── jquery.min.js │ │ │ ├── jquery.min.map │ │ │ ├── jquery.slim.js │ │ │ ├── jquery.slim.min.js │ │ │ └── jquery.slim.min.map │ ├── Lab7 │ │ ├── .gitignore │ │ ├── ClientApp │ │ │ ├── .editorconfig │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── angular.json │ │ │ ├── e2e │ │ │ │ ├── protractor.conf.js │ │ │ │ ├── src │ │ │ │ │ ├── app.e2e-spec.ts │ │ │ │ │ └── app.po.ts │ │ │ │ └── tsconfig.e2e.json │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ ├── src │ │ │ │ ├── app │ │ │ │ │ ├── app.component.css │ │ │ │ │ ├── app.component.html │ │ │ │ │ ├── app.component.ts │ │ │ │ │ ├── app.module.ts │ │ │ │ │ ├── app.server.module.ts │ │ │ │ │ ├── counter │ │ │ │ │ │ ├── counter.component.html │ │ │ │ │ │ ├── counter.component.spec.ts │ │ │ │ │ │ └── counter.component.ts │ │ │ │ │ ├── fetch-data │ │ │ │ │ │ ├── fetch-data.component.html │ │ │ │ │ │ └── fetch-data.component.ts │ │ │ │ │ ├── home │ │ │ │ │ │ ├── home.component.html │ │ │ │ │ │ └── home.component.ts │ │ │ │ │ └── nav-menu │ │ │ │ │ │ ├── nav-menu.component.css │ │ │ │ │ │ ├── nav-menu.component.html │ │ │ │ │ │ └── nav-menu.component.ts │ │ │ │ ├── assets │ │ │ │ │ └── .gitkeep │ │ │ │ ├── browserslist │ │ │ │ ├── environments │ │ │ │ │ ├── environment.prod.ts │ │ │ │ │ └── environment.ts │ │ │ │ ├── index.html │ │ │ │ ├── karma.conf.js │ │ │ │ ├── main.ts │ │ │ │ ├── polyfills.ts │ │ │ │ ├── styles.css │ │ │ │ ├── test.ts │ │ │ │ ├── tsconfig.app.json │ │ │ │ ├── tsconfig.server.json │ │ │ │ ├── tsconfig.spec.json │ │ │ │ └── tslint.json │ │ │ ├── tsconfig.json │ │ │ └── tslint.json │ │ ├── Controllers │ │ │ └── SampleDataController.cs │ │ ├── Lab7.csproj │ │ ├── Pages │ │ │ ├── Error.cshtml │ │ │ ├── Error.cshtml.cs │ │ │ └── _ViewImports.cshtml │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── launchSettings.json │ │ ├── Startup.cs │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── wwwroot │ │ │ └── favicon.ico │ └── Lab8 │ │ ├── Lab8.sln │ │ └── src │ │ └── Lab8 │ │ ├── Controllers │ │ └── ProductsController.cs │ │ ├── Lab8.csproj │ │ ├── Models │ │ └── Product.cs │ │ ├── Program.cs │ │ ├── Properties │ │ └── launchSettings.json │ │ └── Startup.cs └── Images │ ├── install-nuget-package.png │ ├── new-webapp-individual-accounts.PNG │ └── run-with-kestrel.png ├── README.md ├── Slides ├── Intro to ASPNET Core.pptx ├── MVC Applications with ASP.NET Core.pptx └── Single Page Applications.pptx ├── notes ├── 1. Intro to .NET Core ├── 2. MVC Applications with ASP.NET Core.md ├── 3. Introduction to ASP.NET Core.md └── davidnotes.md └── outline.md /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Damian Edwards 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Labs/1. Introduction to the .NET Core SDK.md: -------------------------------------------------------------------------------- 1 | # Introduction to the .NET Core SDK 2 | 3 | ## Setup 4 | Confirm you have followed the [installation steps](../README.md#GettingStarted). 5 | 6 | ## Create and run your first application 7 | 1. Open a command prompt or Powershell 8 | 1. Make a new directory to put your application in and change to it 9 | 10 | ``` 11 | mkdir MyNewApp 12 | cd MyNewApp 13 | ``` 14 | 1. Create a new application by typing `dotnet new console` 15 | 2. Run the application by typing `dotnet run` 16 | 3. Open the `Program.cs` file and change the greeting message 17 | 4. Run the application again using `dotnet run`. Optionally, you can type `dotnet run -v n` to see detailed messages about the application being re-built 18 | 19 | ## Run the project output directly 20 | 1. `dotnet run` checks the project source every time to determine if a re-build is necessary and as such is intended for active development scenarios. 21 | 1. Run the project output directly by typing `dotnet ./bin/Debug/netcoreapp2.2/MyNewApp.dll` 22 | 1. Change the greeting in `Program.cs` again and run the application output directly once more, note that the greeting doesn't change as you didn't re-build the project. 23 | 1. Build the project by typing `dotnet build` 24 | 1. Run the project output directly again and see the greeting has now changed 25 | 26 | ## Explore the project files 27 | 1. Open the `MyNewApp.csproj` file in Visual Studio and explore its contents and try using the IntelliSense to change some project configuration values 28 | 1. Look at the files and directories created when the project is built 29 | 30 | ## Make it a web application 31 | 1. In the `MyNewApp.csproj` file, add a reference to the ASP.NET Core meta-package: 32 | 33 | ``` xml 34 | 35 | 36 | 37 | ``` 38 | 39 | 1. At the command prompt, restore the new dependency by typing `dotnet restore` 40 | 1. Open the `Program.cs` file and add the following `using` statements to the top of the `Program.cs` file: 41 | 42 | ``` c# 43 | using Microsoft.AspNetCore.Builder; 44 | using Microsoft.AspNetCore.Http; 45 | using Microsoft.AspNetCore.Hosting; 46 | ``` 47 | 1. Change the `Main` method to: 48 | 49 | ``` c# 50 | public static void Main(string[] args) 51 | { 52 | var host = new WebHostBuilder() 53 | .UseKestrel() 54 | .Configure(app => app.Run(context => context.Response.WriteAsync("Hello World!"))) 55 | .Build(); 56 | 57 | host.Run(); 58 | } 59 | ``` 60 | 1. At the command prompt, run the application using `dotnet run` 61 | 1. Open a web browser and browse to http://localhost:5000/ to see the greeting 62 | -------------------------------------------------------------------------------- /Labs/6. Working with Razor Tag Helpers.md: -------------------------------------------------------------------------------- 1 | # Working with Razor Tag Helpers 2 | 3 | ## Look at Tag Helpers in the project template 4 | 1. Create a new ASP.NET Core project using the "Web Application" template with "Individual User Accounts" selected. 5 | 6 | ![image](Images/new-webapp-individual-accounts.PNG) 7 | 8 | 1. Open the file `Views/Shared/_Layout.cshtml` 9 | 1. Look at the Tag Helpers being used in the `` element and at the end of the page to render CSS stylesheets and JavaScript files and compare it to the generated HTML output 10 | 11 | ## Create a custom Tag Helper 12 | 1. Create a new class in the application you created above, `public class RepeatTagHelper : TagHelper` and resolve any required namespaces 13 | 1. Add a property `public int Count { get; set; }` 14 | 1. Add an override for the `TagHelper.ProcessAsync()` method which repeats the content via the `output` parameter in a loop for `Count` iterations, e.g.: 15 | 16 | ``` C# 17 | public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) 18 | { 19 | for (int i = 0; i < Count; i++) 20 | { 21 | output.Content.AppendHtml(await output.GetChildContentAsync(useCachedResult: false)); 22 | } 23 | } 24 | ``` 25 | 26 | 1. Open the `_ViewImports.cshtml` file and add a line to register your Tag Helper: `@addTagHelper *, Lab6` (adjust `Lab6` to your project/assembly name) 27 | 1. Open `Views/Home/Index.cshtml` and use your Tag Helper, e.g.: 28 | 29 | ``` HTML 30 | 31 |

I'll be repeated!! @DateTime.UtcNow.Ticks

32 |
33 | ``` 34 | 35 | 1. Run the application again and ensure your Tag Helper is working 36 | 1. Note that the Tag Helper is rendering itself as a `` tag (see it in the rendered HTML). We'll fix that now so that only the contents are rendered. 37 | 1. Open the `RepeatTagHelper` again and in the `ProcessAsync` method add a line to null out the tag name: `output.TagName = null;` 38 | 1. Run the application again and see that the outer tag is no longer rendered 39 | 40 | > **Note:** Completed code for this section is found [/Labs/Code/Lab6](/Labs/Code/Lab6). 41 | 42 | ## Extra if you have time 43 | 1. Experiment with decorating your `RepeatTagHelper` class with the `[HtmlTargetElement()]` attribute to change which HTML tag and/or attribute names it will attach itself to 44 | -------------------------------------------------------------------------------- /Labs/7. Single Page Applications.md: -------------------------------------------------------------------------------- 1 | ## Prerequisites 2 | 1. Verify you have npm 6+ installed (run `npm -v` to check). 3 | 1. Install Webpack globally: 4 | 5 | ``` 6 | npm install -g webpack 7 | ``` 8 | 9 | ## Creating a new Angular application 10 | 1. From a commandline, create and navigate to a new empty directory. 11 | 1. Create a new Angular application using the "angular" scaffolder: 12 | 13 | ``` 14 | dotnet new angular 15 | ``` 16 | 1. View the application code by typing `code .` to launch Visual Studio Code in the current directory. 17 | 1. Build the application using `dotnet build` 18 | 19 | ## Running the Angular application 20 | 1. From the commandline, set the ASP.NET Core development mode environment variable: 21 | 22 | ``` 23 | set ASPNETCORE_ENVIRONMENT=Development 24 | ``` 25 | > **Note**: On OSX this is done using `export ASPNETCORE_ENVIRONMENT=Development` 26 | 27 | 1. Run the application using the `dotnet watch` tool: 28 | 29 | ``` 30 | dotnet watch run 31 | ``` 32 | 1. Navigate to `http://localhost:5000` to view the application. 33 | 34 | > **Note**: Leave the application running and the browser window open for the remainder of the lab. 35 | 36 | ## Experiment with Hot Module Reloading (HMR) 37 | 1. Navigate to the Counter page in running web application. 38 | 1. In Visual Studio Code, Edit the counter implementation ((\ClientApp\app\counter\counter.component.ts) to change the counter increment to 10: 39 | 40 | ```typescript 41 | export class CounterComponent { 42 | public currentCount = 0; 43 | 44 | public incrementCounter() { 45 | this.currentCount+=10; 46 | } 47 | } 48 | ``` 49 | 1. Edit the Counter template (\ClientApp\components\counter\counter.html) to change the H2 heading text. 50 | 1. Observe that the application has refreshed with your changes. View the console output to see the debug messages printed out during the updates. 51 | 52 | ## Extra 53 | 1. Create a React, or React + Redux application using the above steps but selecting a different template when invoking the `dotnet new` command. 54 | -------------------------------------------------------------------------------- /Labs/7.5 App building - Attendee List.md: -------------------------------------------------------------------------------- 1 | # App Building: Attendee List 2 | 3 | Using what you've learnt so far, build a simple application for managing a list of course attendees. Use the requirements below as a guide. 4 | 5 | There is a completed application as a further guide in the [App folder](/Labs/Code/App) of this repository. 6 | 7 | ## Requirements 8 | - You can start with the empty project template or the full project template to get going 9 | - HINT: the full project template (with Individual Auth) enables MVC scaffolding which should make it much easier to build parts of the app 10 | - Use Entity Framework Core to manage data, you can choose to use the in-memory provider, SQL, SQL Lite, etc. 11 | - Don't worry too much about making it look pretty with bootstrap, etc. We're just trying to make the application functional 12 | - Attendees should have the following properties 13 | - FirstName (string, required) 14 | - LastName (string, required) 15 | - Email (string, required) 16 | - Company (string) 17 | - There should be pages to: 18 | - List attendees (/) 19 | - View an attendee's details (/{id}) 20 | - Create an attendee (/create) 21 | - Edit an attendee's details (/{id}/edit) 22 | - Delete an attendee (with a confirmation form) (/{id}/delete) 23 | - Pages should include validation for create and update operations 24 | - HINT: Check `ModelState.IsValid` and use the validation attributes on the model class and validation Tag Helpers in the forms 25 | - There should be JSON web APIs to: 26 | - List attendees (GET) 27 | - Retrieve an attendee's details (GET) 28 | - Create an attendee (POST) 29 | - Update an attendee's details (PUT) 30 | - Delete an attendee (DELETE) 31 | - APIs should validate changes for create and update operations and return suitable HTTP responses for operations 32 | - HINT: Use the `CreatedAtAction`, `BadRequest`, and `NoContent` helper methods to return appropriate HTTP status results 33 | - Enable downloading an attendee as a [vCard](https://en.wikipedia.org/wiki/VCard) contact 34 | - HINT: Use a custom `OutputFormatter` and the `Produces` attribute 35 | 36 | ## Extra Credit 37 | - Add a [layout](https://docs.asp.net/en/latest/mvc/views/layout.html) and some basic Bootstrap styles. 38 | - Add unit tests for your controllers. 39 | - Build a front-end client (SPA or perhaps another application type) that consumes your API. -------------------------------------------------------------------------------- /Labs/8.1 Hosting & Deployment.md: -------------------------------------------------------------------------------- 1 | # Hosting & Deployment 2 | 3 | ## Prerequisites (deploying to Azure) 4 | - Sign up for an Azure account https://azure.microsoft.com/en-us/pricing/free-trial/ 5 | - Download Azure Development tools for Visual Studio https://azure.microsoft.com/en-us/tools/ 6 | - Download and configure git (https://git-scm.com/) if you don't already have it 7 | - Log into Visual Studio (Windows only) 8 | - We're going to be deploying the application you built in the previous lab 9 | 10 | ## Deploy via Visual Studio (Windows only) 11 | 12 | 1. Right click on the project and click publish and click on **Microsoft Azure App Service**: 13 | 14 | ![image](https://cloud.githubusercontent.com/assets/95136/15857377/671e1e50-2cbb-11e6-8a8e-ba7873213e67.png) 15 | 16 | 1. Create a new resource group and name it after your project 17 | 18 | ![image](https://cloud.githubusercontent.com/assets/95136/15857406/91a0a116-2cbb-11e6-8fcc-e0bc8dfed211.png) 19 | 20 | 1. Once the resource group is created, follow the instructions and deploy the site to Azure. 21 | 22 | ## Deploy via git 23 | 24 | - https://docs.asp.net/en/latest/publishing/azure-continuous-deployment.html -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28010.2041 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AttendeeList", "AttendeeList\AttendeeList.csproj", "{D98E4CBE-7E80-47F0-BBB3-F3585F3ED11A}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {D98E4CBE-7E80-47F0-BBB3-F3585F3ED11A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {D98E4CBE-7E80-47F0-BBB3-F3585F3ED11A}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {D98E4CBE-7E80-47F0-BBB3-F3585F3ED11A}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {D98E4CBE-7E80-47F0-BBB3-F3585F3ED11A}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {B66E71C5-07B6-46CD-9CC3-40C517A5EB6E} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": ".NET Core Launch (console)", 6 | "type": "coreclr", 7 | "request": "launch", 8 | "preLaunchTask": "build", 9 | "program": "${workspaceRoot}/bin/Debug/netcoreapp1.0/AttendeeList.dll", 10 | "args": [], 11 | "cwd": "${workspaceRoot}", 12 | "stopAtEntry": false 13 | }, 14 | { 15 | "name": ".NET Core Launch (web)", 16 | "type": "coreclr", 17 | "request": "launch", 18 | "preLaunchTask": "build", 19 | "program": "${workspaceRoot}/bin/Debug/netcoreapp1.0/AttendeeList.dll", 20 | "args": [], 21 | "cwd": "${workspaceRoot}", 22 | "stopAtEntry": false, 23 | "launchBrowser": { 24 | "enabled": true, 25 | "args": "${auto-detect-url}", 26 | "windows": { 27 | "command": "cmd.exe", 28 | "args": "/C start ${auto-detect-url}" 29 | }, 30 | "osx": { 31 | "command": "open" 32 | }, 33 | "linux": { 34 | "command": "xdg-open" 35 | } 36 | } 37 | }, 38 | { 39 | "name": ".NET Core Attach", 40 | "type": "coreclr", 41 | "request": "attach", 42 | "processName": "" 43 | } 44 | ] 45 | } -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.1.0", 3 | "command": "dotnet", 4 | "isShellCommand": true, 5 | "args": [], 6 | "tasks": [ 7 | { 8 | "taskName": "build", 9 | "args": [], 10 | "isBuildCommand": true, 11 | "problemMatcher": "$msCompile" 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/AttendeeList.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/Controllers/PlatformController.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using Microsoft.AspNetCore.Mvc; 3 | 4 | namespace AttendeeList 5 | { 6 | [Route("/api/[controller]")] 7 | public class PlatformController : Controller 8 | { 9 | [HttpGet] 10 | public string Get() 11 | { 12 | return RuntimeInformation.OSDescription; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/Formatters/VCardFormatter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Microsoft.AspNetCore.Http; 8 | using Microsoft.AspNetCore.Mvc.Formatters; 9 | 10 | namespace AttendeeList 11 | { 12 | public class VCardFormatter : OutputFormatter 13 | { 14 | public VCardFormatter() 15 | { 16 | SupportedMediaTypes.Add("text/vcard"); 17 | } 18 | 19 | protected override bool CanWriteType(Type type) 20 | { 21 | return type == typeof(Attendee); 22 | } 23 | 24 | public override void WriteResponseHeaders(OutputFormatterWriteContext context) 25 | { 26 | var attendee = context.Object as Attendee; 27 | var fileName = $"{attendee.FirstName}_{attendee.LastName}.vcf"; 28 | fileName = new string(fileName.Select(c => Path.GetInvalidPathChars().Contains(c) ? '_' : c).ToArray(), 0, fileName.Length); 29 | context.HttpContext.Response.Headers.Add("content-disposition", $"attachment; filename=\"" + fileName + "\""); 30 | } 31 | 32 | public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context) 33 | { 34 | var attendee = context.Object as Attendee; 35 | 36 | FormattableString card = $@"BEGIN:VCARD 37 | VERSION: 3.0 38 | N:{attendee.LastName};{attendee.FirstName};;; 39 | FN:{attendee.FirstName} {attendee.LastName} 40 | EMAIL;type=INTERNET;type=pref:{attendee.Email} 41 | ORG:{attendee.Company}; 42 | END:VCARD"; 43 | 44 | using (var writer = context.WriterFactory(context.HttpContext.Response.Body, Encoding.UTF8)) 45 | { 46 | return writer.WriteAsync(VCardEncoder.Encode(card)); 47 | } 48 | } 49 | 50 | private class VCardEncoder : IFormatProvider, ICustomFormatter 51 | { 52 | public static VCardEncoder Instance = new VCardEncoder(); 53 | 54 | public static string Encode(FormattableString card) 55 | { 56 | return card.ToString(Instance); 57 | } 58 | 59 | public string Format(string format, object arg, IFormatProvider formatProvider) 60 | { 61 | return Encode(arg); 62 | } 63 | 64 | public object GetFormat(Type formatType) 65 | { 66 | return (formatType == typeof(ICustomFormatter)) ? this : null; 67 | } 68 | 69 | private static string Encode(object arg) 70 | { 71 | return arg.ToString() 72 | .Replace("\\", "\\\\") 73 | .Replace(",", "\\,") 74 | .Replace(";", "\\;"); 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/Models/Attendee.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.DataAnnotations; 3 | 4 | namespace AttendeeList 5 | { 6 | public class Attendee 7 | { 8 | public int Id { get; set; } 9 | 10 | [Required] 11 | [Display(Name = "First name")] 12 | public string FirstName { get; set; } 13 | 14 | [Required] 15 | [Display(Name = "Last name")] 16 | public string LastName { get; set; } 17 | 18 | [Display(Name = "E-mail")] 19 | [DataType(DataType.EmailAddress)] 20 | public string Email { get; set; } 21 | 22 | [Required] 23 | public string Company { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/Models/WorkshopContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore; 3 | 4 | namespace AttendeeList 5 | { 6 | public class WorkshopContext : DbContext 7 | { 8 | public WorkshopContext(DbContextOptions options) : base(options) 9 | { 10 | Database.EnsureCreated(); 11 | } 12 | public DbSet Attendees { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore; 2 | using Microsoft.AspNetCore.Builder; 3 | using Microsoft.AspNetCore.Hosting; 4 | 5 | namespace AttendeeList 6 | { 7 | public class Program 8 | { 9 | public static void Main(string[] args) 10 | { 11 | CreateWebHostBuilder(args).Build().Run(); 12 | } 13 | 14 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 15 | WebHost.CreateDefaultBuilder(args) 16 | .UseStartup(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:24737/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.Extensions.Hosting; 4 | using Microsoft.AspNetCore.Mvc; 5 | using Microsoft.EntityFrameworkCore; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.DependencyInjection; 8 | 9 | namespace AttendeeList 10 | { 11 | public class Startup 12 | { 13 | public Startup(IConfiguration configuration) 14 | { 15 | Configuration = configuration; 16 | } 17 | 18 | public IConfiguration Configuration { get; set; } 19 | 20 | // This method gets called by the runtime. Use this method to add services to the container. 21 | // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 22 | public void ConfigureServices(IServiceCollection services) 23 | { 24 | services.AddDbContext(options => 25 | { 26 | options.UseSqlite(Configuration.GetConnectionString("Attendees")); 27 | }); 28 | 29 | services.AddMvc(options => options.OutputFormatters.Add(new VCardFormatter())) 30 | .SetCompatibilityVersion(CompatibilityVersion.Version_2_2); 31 | } 32 | 33 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 34 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 35 | { 36 | if (env.IsDevelopment()) 37 | { 38 | app.UseDeveloperExceptionPage(); 39 | } 40 | 41 | app.UseStaticFiles(); 42 | 43 | app.UseMvc(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/Views/Attendees/Create.cshtml: -------------------------------------------------------------------------------- 1 | @model Attendee 2 | 3 | @{ 4 | Layout = null; 5 | } 6 | 7 | 8 | 9 | 10 | 11 | 12 | Create 13 | 14 | 15 | 16 |
17 |
18 |

Attendee

19 |
20 |
21 |
22 | 23 |
24 | 25 | 26 |
27 |
28 |
29 | 30 |
31 | 32 | 33 |
34 |
35 |
36 | 37 |
38 | 39 | 40 |
41 |
42 |
43 | 44 |
45 | 46 | 47 |
48 |
49 |
50 |
51 | 52 |
53 |
54 |
55 |
56 | 57 |
58 | Back to List 59 |
60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/Views/Attendees/Delete.cshtml: -------------------------------------------------------------------------------- 1 | @model Attendee 2 | 3 | @{ 4 | Layout = null; 5 | } 6 | 7 | 8 | 9 | 10 | 11 | 12 | Delete 13 | 14 | 15 | 16 |

Are you sure you want to delete this?

17 |
18 |

Attendee

19 |
20 |
21 |
22 | @Html.DisplayNameFor(model => model.FirstName) 23 |
24 |
25 | @Html.DisplayFor(model => model.FirstName) 26 |
27 |
28 | @Html.DisplayNameFor(model => model.LastName) 29 |
30 |
31 | @Html.DisplayFor(model => model.LastName) 32 |
33 |
34 | @Html.DisplayNameFor(model => model.Email) 35 |
36 |
37 | @Html.DisplayFor(model => model.Email) 38 |
39 |
40 | @Html.DisplayNameFor(model => model.Company) 41 |
42 |
43 | @Html.DisplayFor(model => model.Company) 44 |
45 |
46 | 47 |
48 |
49 | | 50 | Back to List 51 |
52 |
53 |
54 | 55 | 56 | -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/Views/Attendees/Details.cshtml: -------------------------------------------------------------------------------- 1 | @model Attendee 2 | 3 | @{ 4 | Layout = null; 5 | } 6 | 7 | 8 | 9 | 10 | 11 | 12 | Details 13 | 14 | 15 | 16 |
17 |

Attendee

18 |
19 |
20 |
21 | @Html.DisplayNameFor(model => model.FirstName) 22 |
23 |
24 | @Html.DisplayFor(model => model.FirstName) 25 |
26 |
27 | @Html.DisplayNameFor(model => model.LastName) 28 |
29 |
30 | @Html.DisplayFor(model => model.LastName) 31 |
32 |
33 | @Html.DisplayNameFor(model => model.Email) 34 |
35 |
36 | @Html.DisplayFor(model => model.Email) 37 |
38 |
39 | @Html.DisplayNameFor(model => model.Company) 40 |
41 |
42 | @Html.DisplayFor(model => model.Company) 43 |
44 |
45 |
46 |
47 | Download vCard | 48 | Edit | 49 | Back to List 50 |
51 | 52 | 53 | -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/Views/Attendees/Edit.cshtml: -------------------------------------------------------------------------------- 1 | @model Attendee 2 | 3 | @{ 4 | Layout = null; 5 | } 6 | 7 | 8 | 9 | 10 | 11 | 12 | Edit 13 | 14 | 15 | 16 |
17 |
18 |

Attendee

19 |
20 |
21 | 22 |
23 | 24 |
25 | 26 | 27 |
28 |
29 |
30 | 31 |
32 | 33 | 34 |
35 |
36 |
37 | 38 |
39 | 40 | 41 |
42 |
43 |
44 | 45 |
46 | 47 | 48 |
49 |
50 |
51 |
52 | 53 |
54 |
55 |
56 |
57 | 58 |
59 | Back to List 60 |
61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/Views/Attendees/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @{ 4 | Layout = null; 5 | } 6 | 7 | 8 | 9 | 10 | 11 | 12 | Index 13 | 14 | 15 |

16 | Create New 17 |

18 | 19 | 20 | 21 | 24 | 27 | 30 | 33 | 34 | 35 | 36 | 37 | @foreach (var item in Model) { 38 | 39 | 42 | 45 | 48 | 51 | 57 | 58 | } 59 | 60 |
22 | @Html.DisplayNameFor(model => model.FirstName) 23 | 25 | @Html.DisplayNameFor(model => model.LastName) 26 | 28 | @Html.DisplayNameFor(model => model.Email) 29 | 31 | @Html.DisplayNameFor(model => model.Company) 32 |
40 | @Html.DisplayFor(modelItem => item.FirstName) 41 | 43 | @Html.DisplayFor(modelItem => item.LastName) 44 | 46 | @Html.DisplayFor(modelItem => item.Email) 47 | 49 | @Html.DisplayFor(modelItem => item.Company) 50 | 52 | vCard | 53 | Edit | 54 | Details | 55 | Delete 56 |
61 | 62 | 63 | -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using AttendeeList 2 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings" : { 3 | "Attendees": "Data Source=attendees.db" 4 | } 5 | } -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/wwwroot/lib/bootstrap/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bootstrap", 3 | "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.", 4 | "keywords": [ 5 | "css", 6 | "js", 7 | "less", 8 | "mobile-first", 9 | "responsive", 10 | "front-end", 11 | "framework", 12 | "web" 13 | ], 14 | "homepage": "http://getbootstrap.com", 15 | "license": "MIT", 16 | "moduleType": "globals", 17 | "main": [ 18 | "less/bootstrap.less", 19 | "dist/js/bootstrap.js" 20 | ], 21 | "ignore": [ 22 | "/.*", 23 | "_config.yml", 24 | "CNAME", 25 | "composer.json", 26 | "CONTRIBUTING.md", 27 | "docs", 28 | "js/tests", 29 | "test-infra" 30 | ], 31 | "dependencies": { 32 | "jquery": "1.9.1 - 2" 33 | }, 34 | "version": "3.3.6", 35 | "_release": "3.3.6", 36 | "_resolution": { 37 | "type": "version", 38 | "tag": "v3.3.6", 39 | "commit": "81df608a40bf0629a1dc08e584849bb1e43e0b7a" 40 | }, 41 | "_source": "git://github.com/twbs/bootstrap.git", 42 | "_target": "3.3.6", 43 | "_originalSource": "bootstrap" 44 | } -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2015 Twitter, Inc 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-concepts-workshop/HEAD/Labs/Code/App/AttendeeList/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-concepts-workshop/HEAD/Labs/Code/App/AttendeeList/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-concepts-workshop/HEAD/Labs/Code/App/AttendeeList/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-concepts-workshop/HEAD/Labs/Code/App/AttendeeList/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/wwwroot/lib/bootstrap/dist/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/wwwroot/lib/jquery-validation-unobtrusive/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation-unobtrusive", 3 | "version": "3.2.6", 4 | "homepage": "https://github.com/aspnet/jquery-validation-unobtrusive", 5 | "description": "Add-on to jQuery Validation to enable unobtrusive validation options in data-* attributes.", 6 | "main": [ 7 | "jquery.validate.unobtrusive.js" 8 | ], 9 | "ignore": [ 10 | "**/.*", 11 | "*.json", 12 | "*.md", 13 | "*.txt", 14 | "gulpfile.js" 15 | ], 16 | "keywords": [ 17 | "jquery", 18 | "asp.net", 19 | "mvc", 20 | "validation", 21 | "unobtrusive" 22 | ], 23 | "authors": [ 24 | "Microsoft" 25 | ], 26 | "license": "http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm", 27 | "repository": { 28 | "type": "git", 29 | "url": "git://github.com/aspnet/jquery-validation-unobtrusive.git" 30 | }, 31 | "dependencies": { 32 | "jquery-validation": ">=1.8", 33 | "jquery": ">=1.8" 34 | }, 35 | "_release": "3.2.6", 36 | "_resolution": { 37 | "type": "version", 38 | "tag": "v3.2.6", 39 | "commit": "13386cd1b5947d8a5d23a12b531ce3960be1eba7" 40 | }, 41 | "_source": "git://github.com/aspnet/jquery-validation-unobtrusive.git", 42 | "_target": "3.2.6", 43 | "_originalSource": "jquery-validation-unobtrusive" 44 | } -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/wwwroot/lib/jquery-validation/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation", 3 | "homepage": "http://jqueryvalidation.org/", 4 | "repository": { 5 | "type": "git", 6 | "url": "git://github.com/jzaefferer/jquery-validation.git" 7 | }, 8 | "authors": [ 9 | "Jörn Zaefferer " 10 | ], 11 | "description": "Form validation made easy", 12 | "main": "dist/jquery.validate.js", 13 | "keywords": [ 14 | "forms", 15 | "validation", 16 | "validate" 17 | ], 18 | "license": "MIT", 19 | "ignore": [ 20 | "**/.*", 21 | "node_modules", 22 | "bower_components", 23 | "test", 24 | "demo", 25 | "lib" 26 | ], 27 | "dependencies": { 28 | "jquery": ">= 1.7.2" 29 | }, 30 | "version": "1.14.0", 31 | "_release": "1.14.0", 32 | "_resolution": { 33 | "type": "version", 34 | "tag": "1.14.0", 35 | "commit": "c1343fb9823392aa9acbe1c3ffd337b8c92fed48" 36 | }, 37 | "_source": "git://github.com/jzaefferer/jquery-validation.git", 38 | "_target": ">=1.8", 39 | "_originalSource": "jquery-validation" 40 | } -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/wwwroot/lib/jquery/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "main": "dist/jquery.js", 4 | "license": "MIT", 5 | "ignore": [ 6 | "package.json" 7 | ], 8 | "keywords": [ 9 | "jquery", 10 | "javascript", 11 | "browser", 12 | "library" 13 | ], 14 | "homepage": "https://github.com/jquery/jquery-dist", 15 | "version": "2.2.0", 16 | "_release": "2.2.0", 17 | "_resolution": { 18 | "type": "version", 19 | "tag": "2.2.0", 20 | "commit": "6fc01e29bdad0964f62ef56d01297039cdcadbe5" 21 | }, 22 | "_source": "git://github.com/jquery/jquery-dist.git", 23 | "_target": "2.2.0", 24 | "_originalSource": "jquery" 25 | } -------------------------------------------------------------------------------- /Labs/Code/App/AttendeeList/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright jQuery Foundation and other contributors, https://jquery.org/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /Labs/Code/Lab1/MyNewApp/MyNewApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Labs/Code/Lab1/MyNewApp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Builder; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.AspNetCore.Hosting; 5 | 6 | class Program 7 | { 8 | static void Main(string[] args) 9 | { 10 | var host = new WebHostBuilder() 11 | .UseKestrel() 12 | .Configure(app => app.Run(context => context.Response.WriteAsync("Hello World!"))) 13 | .Build(); 14 | 15 | host.Run(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/Lab2A.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26020.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{81F6D934-5486-4998-B3F5-8868049610AD}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab2A", "src\Lab2A\Lab2A.csproj", "{7BE7C5DC-F1DE-415E-B08A-1C744E709331}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Debug|x64 = Debug|x64 14 | Debug|x86 = Debug|x86 15 | Release|Any CPU = Release|Any CPU 16 | Release|x64 = Release|x64 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {7BE7C5DC-F1DE-415E-B08A-1C744E709331}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {7BE7C5DC-F1DE-415E-B08A-1C744E709331}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {7BE7C5DC-F1DE-415E-B08A-1C744E709331}.Debug|x64.ActiveCfg = Debug|Any CPU 23 | {7BE7C5DC-F1DE-415E-B08A-1C744E709331}.Debug|x64.Build.0 = Debug|Any CPU 24 | {7BE7C5DC-F1DE-415E-B08A-1C744E709331}.Debug|x86.ActiveCfg = Debug|Any CPU 25 | {7BE7C5DC-F1DE-415E-B08A-1C744E709331}.Debug|x86.Build.0 = Debug|Any CPU 26 | {7BE7C5DC-F1DE-415E-B08A-1C744E709331}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {7BE7C5DC-F1DE-415E-B08A-1C744E709331}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {7BE7C5DC-F1DE-415E-B08A-1C744E709331}.Release|x64.ActiveCfg = Release|Any CPU 29 | {7BE7C5DC-F1DE-415E-B08A-1C744E709331}.Release|x64.Build.0 = Release|Any CPU 30 | {7BE7C5DC-F1DE-415E-B08A-1C744E709331}.Release|x86.ActiveCfg = Release|Any CPU 31 | {7BE7C5DC-F1DE-415E-B08A-1C744E709331}.Release|x86.Build.0 = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | GlobalSection(NestedProjects) = preSolution 37 | {7BE7C5DC-F1DE-415E-B08A-1C744E709331} = {81F6D934-5486-4998-B3F5-8868049610AD} 38 | EndGlobalSection 39 | GlobalSection(ExtensibilityGlobals) = postSolution 40 | SolutionGuid = {5AB53B0E-CCA9-4166-9082-6B2734A06E18} 41 | EndGlobalSection 42 | EndGlobal 43 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Areas/Identity/Pages/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "/Views/Shared/_Layout.cshtml"; 3 | } 4 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | namespace Lab2A.Controllers 8 | { 9 | public class HomeController : Controller 10 | { 11 | public IActionResult Index() 12 | { 13 | return View(); 14 | } 15 | 16 | public IActionResult About() 17 | { 18 | ViewData["Message"] = "Your application description page."; 19 | 20 | return View(); 21 | } 22 | 23 | public IActionResult Contact() 24 | { 25 | ViewData["Message"] = "Your contact page."; 26 | 27 | return View(); 28 | } 29 | 30 | public IActionResult Error() 31 | { 32 | return View(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Data/ApplicationDbContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 6 | using Microsoft.EntityFrameworkCore; 7 | using Lab2A.Models; 8 | 9 | namespace Lab2A.Data 10 | { 11 | public class ApplicationDbContext : IdentityDbContext 12 | { 13 | public ApplicationDbContext(DbContextOptions options) 14 | : base(options) 15 | { 16 | } 17 | 18 | protected override void OnModelCreating(ModelBuilder builder) 19 | { 20 | base.OnModelCreating(builder); 21 | // Customize the ASP.NET Identity model and override the defaults if needed. 22 | // For example, you can rename the ASP.NET Identity table names and more. 23 | // Add your customizations after calling base.OnModelCreating(builder); 24 | } 25 | 26 | public DbSet Person { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Data/Migrations/20170116070549_Person Class.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Microsoft.EntityFrameworkCore.Migrations; 4 | using Microsoft.EntityFrameworkCore.Metadata; 5 | 6 | namespace Lab2A.Data.Migrations 7 | { 8 | public partial class PersonClass : Migration 9 | { 10 | protected override void Up(MigrationBuilder migrationBuilder) 11 | { 12 | migrationBuilder.CreateTable( 13 | name: "Person", 14 | columns: table => new 15 | { 16 | ID = table.Column(nullable: false) 17 | .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), 18 | Age = table.Column(nullable: false), 19 | Name = table.Column(nullable: true) 20 | }, 21 | constraints: table => 22 | { 23 | table.PrimaryKey("PK_Person", x => x.ID); 24 | }); 25 | } 26 | 27 | protected override void Down(MigrationBuilder migrationBuilder) 28 | { 29 | migrationBuilder.DropTable( 30 | name: "Person"); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Lab2A.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | InProcess 6 | 7 | 8 | 9 | aspnet-Lab2A-6e24e18a-afa0-4910-a02c-7e231d23b881 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Models/ApplicationUser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Identity; 6 | 7 | namespace Lab2A.Models 8 | { 9 | // Add profile data for application users by adding properties to the ApplicationUser class 10 | public class ApplicationUser : IdentityUser 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Models/Person.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace Lab2A.Models 7 | { 8 | public class Person 9 | { 10 | public int ID { get; set; } 11 | public string Name { get; set; } 12 | public int Age { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.Extensions.Hosting; 8 | 9 | namespace Lab2A 10 | { 11 | public class Program 12 | { 13 | public static void Main(string[] args) 14 | { 15 | CreateHostBuilder(args).Build().Run(); 16 | } 17 | 18 | public static IHostBuilder CreateHostBuilder(string[] args) => 19 | Host.CreateDefaultBuilder(args) 20 | .ConfigureWebHostDefaults(webBuilder => 21 | { 22 | webBuilder.UseContentRoot(Directory.GetCurrentDirectory()) 23 | .UseIISIntegration() 24 | .UseStartup(); 25 | }); 26 | } 27 | } -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:61496/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Lab2A": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "http://localhost:61497" 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Services/IEmailSender.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace Lab2A.Services 7 | { 8 | public interface IEmailSender 9 | { 10 | Task SendEmailAsync(string email, string subject, string message); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Services/ISmsSender.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace Lab2A.Services 7 | { 8 | public interface ISmsSender 9 | { 10 | Task SendSmsAsync(string number, string message); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Services/MessageServices.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace Lab2A.Services 7 | { 8 | // This class is used by the application to send Email and SMS 9 | // when you turn on two-factor authentication in ASP.NET Identity. 10 | // For more details see this link http://go.microsoft.com/fwlink/?LinkID=532713 11 | public class AuthMessageSender : IEmailSender, ISmsSender 12 | { 13 | public Task SendEmailAsync(string email, string subject, string message) 14 | { 15 | // Plug in your email service here to send an email. 16 | return Task.FromResult(0); 17 | } 18 | 19 | public Task SendSmsAsync(string number, string message) 20 | { 21 | // Plug in your SMS service here to send a text message. 22 | return Task.FromResult(0); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Views/Home/About.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "About"; 3 | } 4 |

@ViewData["Title"].

5 |

@ViewData["Message"]

6 | 7 |

Use this area to provide additional information.

8 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Views/Home/Contact.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Contact"; 3 | } 4 |

@ViewData["Title"].

5 |

@ViewData["Message"]

6 | 7 |
8 | One Microsoft Way
9 | Redmond, WA 98052-6399
10 | P: 11 | 425.555.0100 12 |
13 | 14 |
15 | Support: Support@example.com
16 | Marketing: Marketing@example.com 17 |
18 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Views/People/Create.cshtml: -------------------------------------------------------------------------------- 1 | @model Lab2A.Models.Person 2 | 3 | @{ 4 | ViewData["Title"] = "Create"; 5 | } 6 | 7 |

Create

8 | 9 |
10 |
11 |

Person

12 |
13 |
14 |
15 | 16 |
17 | 18 | 19 |
20 |
21 |
22 | 23 |
24 | 25 | 26 |
27 |
28 |
29 |
30 | 31 |
32 |
33 |
34 |
35 | 36 |
37 | Back to List 38 |
39 | 40 | @section Scripts { 41 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} 42 | } 43 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Views/People/Delete.cshtml: -------------------------------------------------------------------------------- 1 | @model Lab2A.Models.Person 2 | 3 | @{ 4 | ViewData["Title"] = "Delete"; 5 | } 6 | 7 |

Delete

8 | 9 |

Are you sure you want to delete this?

10 |
11 |

Person

12 |
13 |
14 |
15 | @Html.DisplayNameFor(model => model.Name) 16 |
17 |
18 | @Html.DisplayFor(model => model.Name) 19 |
20 |
21 | @Html.DisplayNameFor(model => model.Age) 22 |
23 |
24 | @Html.DisplayFor(model => model.Age) 25 |
26 |
27 | 28 |
29 |
30 | | 31 | Back to List 32 |
33 |
34 |
35 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Views/People/Details.cshtml: -------------------------------------------------------------------------------- 1 | @model Lab2A.Models.Person 2 | 3 | @{ 4 | ViewData["Title"] = "Details"; 5 | } 6 | 7 |

Details

8 | 9 |
10 |

Person

11 |
12 |
13 |
14 | @Html.DisplayNameFor(model => model.Name) 15 |
16 |
17 | @Html.DisplayFor(model => model.Name) 18 |
19 |
20 | @Html.DisplayNameFor(model => model.Age) 21 |
22 |
23 | @Html.DisplayFor(model => model.Age) 24 |
25 |
26 |
27 |
28 | Edit | 29 | Back to List 30 |
31 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Views/People/Edit.cshtml: -------------------------------------------------------------------------------- 1 | @model Lab2A.Models.Person 2 | 3 | @{ 4 | ViewData["Title"] = "Edit"; 5 | } 6 | 7 |

Edit

8 | 9 |
10 |
11 |

Person

12 |
13 |
14 | 15 |
16 | 17 |
18 | 19 | 20 |
21 |
22 |
23 | 24 |
25 | 26 | 27 |
28 |
29 |
30 |
31 | 32 |
33 |
34 |
35 |
36 | 37 |
38 | Back to List 39 |
40 | 41 | @section Scripts { 42 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} 43 | } 44 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Views/People/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @{ 4 | ViewData["Title"] = "Index"; 5 | } 6 | 7 |

Index

8 | 9 |

10 | Create New 11 |

12 | 13 | 14 | 15 | 18 | 21 | 22 | 23 | 24 | 25 | @foreach (var item in Model) { 26 | 27 | 30 | 33 | 38 | 39 | } 40 | 41 |
16 | @Html.DisplayNameFor(model => model.Name) 17 | 19 | @Html.DisplayNameFor(model => model.Age) 20 |
28 | @Html.DisplayFor(modelItem => item.Name) 29 | 31 | @Html.DisplayFor(modelItem => item.Age) 32 | 34 | Edit | 35 | Details | 36 | Delete 37 |
42 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Error"; 3 | } 4 | 5 |

Error.

6 |

An error occurred while processing your request.

7 | 8 |

Development Mode

9 |

10 | Swapping to Development environment will display more detailed information about the error that occurred. 11 |

12 |

13 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. 14 |

15 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Views/Shared/_LoginPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Identity 2 | @using Lab2A.Models 3 | 4 | @inject SignInManager SignInManager 5 | @inject UserManager UserManager 6 | 7 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using Lab2A 2 | @using Lab2A.Models 3 | @using Microsoft.AspNetCore.Identity 4 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 5 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-Lab2A-e81531cc-6102-4a4e-b67b-be788c9c5667;Trusted_Connection=True;MultipleActiveResultSets=true" 4 | }, 5 | "Logging": { 6 | "IncludeScopes": false, 7 | "LogLevel": { 8 | "Default": "Debug", 9 | "System": "Information", 10 | "Microsoft": "Information" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/bundleconfig.json: -------------------------------------------------------------------------------- 1 | // Configure bundling and minification for the project. 2 | // More info at https://go.microsoft.com/fwlink/?LinkId=808241 3 | [ 4 | { 5 | "outputFileName": "wwwroot/css/site.min.css", 6 | // An array of relative input file paths. Globbing patterns supported 7 | "inputFiles": [ 8 | "wwwroot/css/site.css" 9 | ] 10 | }, 11 | { 12 | "outputFileName": "wwwroot/js/site.min.js", 13 | "inputFiles": [ 14 | "wwwroot/js/site.js" 15 | ], 16 | // Optionally specify minification options 17 | "minify": { 18 | "enabled": true, 19 | "renameLocals": true 20 | }, 21 | // Optionally generate .map file 22 | "sourceMap": false 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/libman.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "defaultProvider": "cdnjs", 4 | "libraries": [ 5 | { 6 | "library": "jquery@3.4.1", 7 | "destination": "wwwroot/lib/jquery/" 8 | }, 9 | { 10 | "library": "jquery-validation-unobtrusive@3.2.11", 11 | "destination": "wwwroot/lib/jquery-validation-unobtrusive/" 12 | }, 13 | { 14 | "provider": "unpkg", 15 | "library": "bootstrap@4.3.1", 16 | "destination": "wwwroot/lib/bootstrap/" 17 | }, 18 | { 19 | "provider": "unpkg", 20 | "library": "jquery-validation@1.19.0", 21 | "destination": "wwwroot/lib/jquery-validation/" 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Sticky footer styles 11 | -------------------------------------------------- */ 12 | html { 13 | font-size: 14px; 14 | } 15 | 16 | @media (min-width: 768px) { 17 | html { 18 | font-size: 16px; 19 | } 20 | } 21 | 22 | .border-top { 23 | border-top: 1px solid #e5e5e5; 24 | } 25 | 26 | .border-bottom { 27 | border-bottom: 1px solid #e5e5e5; 28 | } 29 | 30 | .box-shadow { 31 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 32 | } 33 | 34 | button.accept-policy { 35 | font-size: 1rem; 36 | line-height: inherit; 37 | } 38 | 39 | /* Sticky footer styles 40 | -------------------------------------------------- */ 41 | html { 42 | position: relative; 43 | min-height: 100%; 44 | } 45 | 46 | body { 47 | /* Margin bottom by footer height */ 48 | margin-bottom: 60px; 49 | } 50 | 51 | .footer { 52 | position: absolute; 53 | bottom: 0; 54 | width: 100%; 55 | white-space: nowrap; 56 | /* Set the fixed height of the footer here */ 57 | height: 60px; 58 | line-height: 60px; /* Vertically center the text there */ 59 | } 60 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/wwwroot/css/site.min.css: -------------------------------------------------------------------------------- 1 | body{padding-top:50px;padding-bottom:20px}.body-content{padding-left:15px;padding-right:15px}input,select,textarea{max-width:280px}.carousel-caption p{font-size:20px;line-height:1.4}.btn-bracketed::before{display:inline-block;content:"[";padding-right:.5em}.btn-bracketed::after{display:inline-block;content:"]";padding-left:.5em}.carousel-inner .item img[src$=".svg"]{width:100%}@media screen and (max-width:767px){.carousel-caption{display:none}} -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-concepts-workshop/HEAD/Labs/Code/Lab2A/src/Lab2A/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Write your Javascript code. 2 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/wwwroot/js/site.min.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2019 Twitter, Inc. 4 | Copyright (c) 2011-2019 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Labs/Code/Lab2A/src/Lab2A/wwwroot/lib/jquery-validation/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation", 3 | "title": "jQuery Validation Plugin", 4 | "description": "Client-side form validation made easy", 5 | "version": "1.19.0", 6 | "homepage": "https://jqueryvalidation.org/", 7 | "license": "MIT", 8 | "author": { 9 | "name": "Jörn Zaefferer", 10 | "email": "joern.zaefferer@gmail.com", 11 | "url": "http://bassistance.de" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "git://github.com/jquery-validation/jquery-validation.git" 16 | }, 17 | "bugs": { 18 | "url": "https://github.com/jquery-validation/jquery-validation/issues" 19 | }, 20 | "licenses": [ 21 | { 22 | "type": "MIT", 23 | "url": "https://www.opensource.org/licenses/MIT" 24 | } 25 | ], 26 | "scripts": { 27 | "test": "grunt", 28 | "prepublish": "grunt" 29 | }, 30 | "files": [ 31 | "dist/localization/", 32 | "dist/additional-methods.js", 33 | "dist/additional-methods.min.js", 34 | "dist/jquery.validate.js", 35 | "dist/jquery.validate.min.js" 36 | ], 37 | "main": "dist/jquery.validate.js", 38 | "dependencies": { 39 | "jquery": "^1.7 || ^2.0 || ^3.1" 40 | }, 41 | "devDependencies": { 42 | "commitplease": "2.3.1", 43 | "grunt": "1.0.1", 44 | "grunt-contrib-compress": "1.2.0", 45 | "grunt-contrib-concat": "1.0.1", 46 | "grunt-contrib-copy": "1.0.0", 47 | "grunt-contrib-jshint": "1.0.0", 48 | "grunt-contrib-qunit": "1.2.0", 49 | "grunt-contrib-uglify": "1.0.1", 50 | "grunt-contrib-watch": "1.0.0", 51 | "grunt-jscs": "2.8.0", 52 | "grunt-sri": "0.2.0", 53 | "grunt-text-replace": "0.4.0", 54 | "qunitjs": "2.3.3" 55 | }, 56 | "keywords": [ 57 | "jquery", 58 | "jquery-plugin", 59 | "forms", 60 | "validation", 61 | "validate" 62 | ] 63 | } 64 | -------------------------------------------------------------------------------- /Labs/Code/Lab2B/Lab2B.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26020.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{14917E84-0349-44AA-9E50-EECB3DAB9976}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab2", "src\Lab2\Lab2.csproj", "{3B55DFDA-79ED-4938-903F-5ED05C76ACB7}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Debug|x64 = Debug|x64 14 | Debug|x86 = Debug|x86 15 | Release|Any CPU = Release|Any CPU 16 | Release|x64 = Release|x64 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x64.ActiveCfg = Debug|Any CPU 23 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x64.Build.0 = Debug|Any CPU 24 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x86.ActiveCfg = Debug|Any CPU 25 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x86.Build.0 = Debug|Any CPU 26 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x64.ActiveCfg = Release|Any CPU 29 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x64.Build.0 = Release|Any CPU 30 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x86.ActiveCfg = Release|Any CPU 31 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x86.Build.0 = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | GlobalSection(NestedProjects) = preSolution 37 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7} = {14917E84-0349-44AA-9E50-EECB3DAB9976} 38 | EndGlobalSection 39 | GlobalSection(ExtensibilityGlobals) = postSolution 40 | SolutionGuid = {421476E7-27B6-454A-9C62-C7D304D3A723} 41 | EndGlobalSection 42 | EndGlobal 43 | -------------------------------------------------------------------------------- /Labs/Code/Lab2B/src/Lab2/Lab2.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netcoreapp3.1 4 | true 5 | 6 | -------------------------------------------------------------------------------- /Labs/Code/Lab2B/src/Lab2/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.Extensions.Hosting; 4 | 5 | namespace Lab2 6 | { 7 | public class Program 8 | { 9 | public static void Main(string[] args) 10 | { 11 | CreateHostBuilder(args).Build().Run(); 12 | } 13 | 14 | public static IHostBuilder CreateHostBuilder(string[] args) => 15 | Host.CreateDefaultBuilder(args) 16 | .ConfigureWebHostDefaults(webBuilder => 17 | { 18 | webBuilder.UseUrls("http://localhost:8081") 19 | .UseStartup(); 20 | }); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Labs/Code/Lab2B/src/Lab2/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:55740/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Lab2": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "launchUrl": "http://localhost:8081", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Production" 24 | }, 25 | "applicationUrl": "http://localhost:55741" 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Labs/Code/Lab2B/src/Lab2/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.AspNetCore.Routing; 5 | using Microsoft.Extensions.Configuration; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using Microsoft.Extensions.Hosting; 8 | 9 | namespace Lab2 10 | { 11 | public class Startup 12 | { 13 | // This method gets called by the runtime. Use this method to add services to the container. 14 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 15 | public void ConfigureServices(IServiceCollection services) 16 | { 17 | services.AddRouting(); 18 | } 19 | 20 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 21 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 22 | { 23 | if (env.IsDevelopment()) 24 | { 25 | app.UseDeveloperExceptionPage(); 26 | } 27 | 28 | var routeBuilder = new RouteBuilder(app); 29 | 30 | routeBuilder.MapGet("", context => context.Response.WriteAsync("Hello from Routing!")); 31 | routeBuilder.MapGet("sub", context => context.Response.WriteAsync("Hello from sub!")); 32 | //routeBuilder.MapGet("item/{itemName}", context => context.Response.WriteAsync($"Item: {context.GetRouteValue("itemName")}")); 33 | routeBuilder.MapGet("item/{id:int}", context => context.Response.WriteAsync($"Item ID: {context.GetRouteValue("id")}")); 34 | 35 | app.UseRouter(routeBuilder.Build()); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Labs/Code/Lab2B/src/Lab2/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "message": "Hello from configuration" 3 | } -------------------------------------------------------------------------------- /Labs/Code/Lab2B/src/Lab2/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

Hello from ASP.NET Core!

9 | 10 | -------------------------------------------------------------------------------- /Labs/Code/Lab2C/Lab2C.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26020.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{14917E84-0349-44AA-9E50-EECB3DAB9976}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab2", "src\Lab2\Lab2.csproj", "{3B55DFDA-79ED-4938-903F-5ED05C76ACB7}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Debug|x64 = Debug|x64 14 | Debug|x86 = Debug|x86 15 | Release|Any CPU = Release|Any CPU 16 | Release|x64 = Release|x64 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x64.ActiveCfg = Debug|Any CPU 23 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x64.Build.0 = Debug|Any CPU 24 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x86.ActiveCfg = Debug|Any CPU 25 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x86.Build.0 = Debug|Any CPU 26 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x64.ActiveCfg = Release|Any CPU 29 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x64.Build.0 = Release|Any CPU 30 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x86.ActiveCfg = Release|Any CPU 31 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x86.Build.0 = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | GlobalSection(NestedProjects) = preSolution 37 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7} = {14917E84-0349-44AA-9E50-EECB3DAB9976} 38 | EndGlobalSection 39 | GlobalSection(ExtensibilityGlobals) = postSolution 40 | SolutionGuid = {A4BCD168-B244-460C-A031-2EFD0FB8FD54} 41 | EndGlobalSection 42 | EndGlobal 43 | -------------------------------------------------------------------------------- /Labs/Code/Lab2C/src/Lab2/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | public class HomeController 4 | { 5 | [HttpGet("/")] 6 | public string Index() => "Hello from MVC!"; 7 | } 8 | -------------------------------------------------------------------------------- /Labs/Code/Lab2C/src/Lab2/Lab2.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netcoreapp3.1 4 | true 5 | 6 | -------------------------------------------------------------------------------- /Labs/Code/Lab2C/src/Lab2/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Hosting; 3 | 4 | namespace Lab2 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | CreateHostBuilder(args).Build().Run(); 11 | } 12 | 13 | public static IHostBuilder CreateHostBuilder(string[] args) => 14 | Host.CreateDefaultBuilder(args) 15 | .ConfigureWebHostDefaults(webBuilder => 16 | { 17 | webBuilder.UseUrls("http://localhost:8081") 18 | .UseStartup(); 19 | }); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Labs/Code/Lab2C/src/Lab2/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:55740/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Lab2": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "launchUrl": "http://localhost:8081", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Production" 24 | }, 25 | "applicationUrl": "http://localhost:55741" 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Labs/Code/Lab2C/src/Lab2/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Hosting; 5 | 6 | namespace Lab2 7 | { 8 | public class Startup 9 | { 10 | // This method gets called by the runtime. Use this method to add services to the container. 11 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 12 | public void ConfigureServices(IServiceCollection services) 13 | { 14 | services.AddControllers(); 15 | } 16 | 17 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 18 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 19 | { 20 | if (env.IsDevelopment()) 21 | { 22 | app.UseDeveloperExceptionPage(); 23 | } 24 | 25 | app.UseRouting(); 26 | app.UseEndpoints(options => options.MapControllers()); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Labs/Code/Lab2C/src/Lab2/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "message": "Hello from configuration" 3 | } -------------------------------------------------------------------------------- /Labs/Code/Lab2C/src/Lab2/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

Hello from ASP.NET Core!

9 | 10 | -------------------------------------------------------------------------------- /Labs/Code/Lab3/Lab3.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26020.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{14917E84-0349-44AA-9E50-EECB3DAB9976}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab3", "src\Lab3\Lab3.csproj", "{3B55DFDA-79ED-4938-903F-5ED05C76ACB7}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Debug|x64 = Debug|x64 14 | Debug|x86 = Debug|x86 15 | Release|Any CPU = Release|Any CPU 16 | Release|x64 = Release|x64 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x64.ActiveCfg = Debug|Any CPU 23 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x64.Build.0 = Debug|Any CPU 24 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x86.ActiveCfg = Debug|Any CPU 25 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x86.Build.0 = Debug|Any CPU 26 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x64.ActiveCfg = Release|Any CPU 29 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x64.Build.0 = Release|Any CPU 30 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x86.ActiveCfg = Release|Any CPU 31 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x86.Build.0 = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | GlobalSection(NestedProjects) = preSolution 37 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7} = {14917E84-0349-44AA-9E50-EECB3DAB9976} 38 | EndGlobalSection 39 | GlobalSection(ExtensibilityGlobals) = postSolution 40 | SolutionGuid = {97312172-3490-4EA1-8316-EAD8F22C3AEF} 41 | EndGlobalSection 42 | EndGlobal 43 | -------------------------------------------------------------------------------- /Labs/Code/Lab3/src/Lab3/Lab3.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netcoreapp3.1 4 | true 5 | 6 | -------------------------------------------------------------------------------- /Labs/Code/Lab3/src/Lab3/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Hosting; 3 | 4 | namespace Lab3 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | CreateHostBuilder(args).Build().Run(); 11 | } 12 | 13 | public static IHostBuilder CreateHostBuilder(string[] args) => 14 | Host.CreateDefaultBuilder(args) 15 | .ConfigureWebHostDefaults(webBuilder => 16 | { 17 | webBuilder.UseUrls("http://localhost:8081") 18 | .UseStartup(); 19 | }); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Labs/Code/Lab3/src/Lab3/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:55740/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Lab3": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "launchUrl": "http://localhost:8081", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Production" 24 | }, 25 | "applicationUrl": "http://localhost:55741" 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Labs/Code/Lab3/src/Lab3/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.Extensions.Configuration; 5 | using Microsoft.Extensions.DependencyInjection; 6 | using Microsoft.Extensions.Hosting; 7 | 8 | namespace Lab3 9 | { 10 | public class Startup 11 | { 12 | public IConfiguration Configuration { get; private set; } 13 | 14 | public Startup(IConfiguration configuration) 15 | { 16 | Configuration = configuration; 17 | } 18 | 19 | // This method gets called by the runtime. Use this method to add services to the container. 20 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 21 | public void ConfigureServices(IServiceCollection services) 22 | { 23 | } 24 | 25 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 26 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 27 | { 28 | if (env.IsDevelopment()) 29 | { 30 | app.UseDeveloperExceptionPage(); 31 | } 32 | 33 | //app.UseFileServer(); 34 | 35 | app.Run(async (context) => 36 | { 37 | //await context.Response.WriteAsync($"Hello World! {env.EnvironmentName}"); 38 | await context.Response.WriteAsync($"{Configuration["message"]}"); 39 | }); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Labs/Code/Lab3/src/Lab3/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "message": "Hello from configuration" 3 | } -------------------------------------------------------------------------------- /Labs/Code/Lab3/src/Lab3/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

Hello from ASP.NET Core!

9 | 10 | -------------------------------------------------------------------------------- /Labs/Code/Lab4A/Lab4A.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.28917.182 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{665FCCEE-47C5-4936-ADA0-F7E3A0430E87}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab4A", "src\Lab4A\Lab4A.csproj", "{091CD54A-0190-4CFC-A20E-BABD61799536}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {091CD54A-0190-4CFC-A20E-BABD61799536}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {091CD54A-0190-4CFC-A20E-BABD61799536}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {091CD54A-0190-4CFC-A20E-BABD61799536}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {091CD54A-0190-4CFC-A20E-BABD61799536}.Release|Any CPU.Build.0 = Release|Any CPU 20 | EndGlobalSection 21 | GlobalSection(SolutionProperties) = preSolution 22 | HideSolutionNode = FALSE 23 | EndGlobalSection 24 | GlobalSection(NestedProjects) = preSolution 25 | {091CD54A-0190-4CFC-A20E-BABD61799536} = {665FCCEE-47C5-4936-ADA0-F7E3A0430E87} 26 | EndGlobalSection 27 | GlobalSection(ExtensibilityGlobals) = postSolution 28 | SolutionGuid = {A48721F1-1019-474D-A0B3-01473772CC2D} 29 | EndGlobalSection 30 | EndGlobal 31 | -------------------------------------------------------------------------------- /Labs/Code/Lab4A/src/Lab4A/Lab4A.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netcoreapp3.1 4 | true 5 | 6 | -------------------------------------------------------------------------------- /Labs/Code/Lab4A/src/Lab4A/Middleware/RequestIdMiddleware.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.Extensions.Logging; 3 | using System.Threading.Tasks; 4 | 5 | public class RequestIdMiddleware 6 | { 7 | private readonly RequestDelegate _next; 8 | private readonly ILogger _logger; 9 | 10 | public RequestIdMiddleware(RequestDelegate next, ILogger logger) 11 | { 12 | _next = next; 13 | _logger = logger; 14 | } 15 | 16 | public Task Invoke(HttpContext context, IRequestId requestId) 17 | { 18 | _logger.LogInformation($"Request {requestId.Id} executing."); 19 | 20 | return _next(context); 21 | } 22 | } -------------------------------------------------------------------------------- /Labs/Code/Lab4A/src/Lab4A/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Hosting; 9 | 10 | namespace Lab4A 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Labs/Code/Lab4A/src/Lab4A/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:61849/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Lab4": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "launchUrl": "http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Labs/Code/Lab4A/src/Lab4A/Services/RequestId.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | 3 | public interface IRequestIdFactory 4 | { 5 | string MakeRequestId(); 6 | } 7 | 8 | public class RequestIdFactory : IRequestIdFactory 9 | { 10 | private int _requestId; 11 | 12 | public string MakeRequestId() => Interlocked.Increment(ref _requestId).ToString(); 13 | } 14 | 15 | public interface IRequestId 16 | { 17 | string Id { get; } 18 | } 19 | 20 | public class RequestId : IRequestId 21 | { 22 | private readonly string _requestId; 23 | 24 | public RequestId(IRequestIdFactory requestIdFactory) 25 | { 26 | _requestId = requestIdFactory.MakeRequestId(); 27 | } 28 | 29 | public string Id => _requestId; 30 | } -------------------------------------------------------------------------------- /Labs/Code/Lab4A/src/Lab4A/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.Extensions.DependencyInjection; 5 | 6 | namespace Lab4A 7 | { 8 | public class Startup 9 | { 10 | // This method gets called by the runtime. Use this method to add services to the container. 11 | // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 12 | public void ConfigureServices(IServiceCollection services) 13 | { 14 | services.AddSingleton(); 15 | services.AddScoped(); 16 | } 17 | 18 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 19 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 20 | { 21 | if (env.IsDevelopment()) 22 | { 23 | app.UseDeveloperExceptionPage(); 24 | } 25 | 26 | app.UseMiddleware(); 27 | 28 | app.Run(async (context) => 29 | { 30 | await context.Response.WriteAsync("Hello World!"); 31 | }); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Labs/Code/Lab4B/Lab4B.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.28917.182 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4B", "src\Lab4B.csproj", "{1B524C9F-B407-4B89-A53A-B89BE5B371FE}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {1B524C9F-B407-4B89-A53A-B89BE5B371FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {1B524C9F-B407-4B89-A53A-B89BE5B371FE}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {1B524C9F-B407-4B89-A53A-B89BE5B371FE}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {1B524C9F-B407-4B89-A53A-B89BE5B371FE}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {8FF55818-A41B-4C88-BF8C-64D74EECEA0B} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Labs/Code/Lab4B/src/Lab4B.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | InProcess 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Labs/Code/Lab4B/src/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.Extensions.Configuration; 4 | using Microsoft.Extensions.Hosting; 5 | 6 | namespace Lab4B 7 | { 8 | public class Program 9 | { 10 | public static void Main(string[] args) 11 | { 12 | CreateHostBuilder(args).Build().Run(); 13 | } 14 | 15 | public static IHostBuilder CreateHostBuilder(string[] args) => 16 | Host.CreateDefaultBuilder(args) 17 | .ConfigureWebHostDefaults(webBuilder => 18 | { 19 | webBuilder 20 | .ConfigureAppConfiguration((builderContext, config) => 21 | { 22 | config.AddJsonFile("config.json"); 23 | }) 24 | .UseStartup(); 25 | }); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Labs/Code/Lab4B/src/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:58029", 7 | "sslPort": 44334 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "WebApplication2": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Labs/Code/Lab4B/src/RequestCultureMiddleware.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Http; 3 | using Microsoft.Extensions.Options; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Globalization; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace Lab4B 11 | { 12 | public class RequestCultureMiddleware 13 | { 14 | private readonly RequestDelegate _next; 15 | private readonly RequestCultureOptions _options; 16 | 17 | public RequestCultureMiddleware(RequestDelegate next, IOptions options) 18 | { 19 | _next = next; 20 | _options = options.Value; 21 | } 22 | 23 | public Task Invoke(HttpContext httpContext) 24 | { 25 | CultureInfo requestCulture = null; 26 | 27 | var cultureQuery = httpContext.Request.Query["culture"]; 28 | if (!string.IsNullOrWhiteSpace(cultureQuery)) 29 | { 30 | requestCulture = new CultureInfo(cultureQuery); 31 | } 32 | else 33 | { 34 | requestCulture = _options.DefaultCulture; 35 | } 36 | 37 | if (requestCulture != null) 38 | { 39 | CultureInfo.CurrentCulture = requestCulture; 40 | CultureInfo.CurrentUICulture = requestCulture; 41 | } 42 | 43 | return _next(httpContext); 44 | } 45 | } 46 | 47 | public static class RequestCultureMiddlewareExtensions 48 | { 49 | public static IApplicationBuilder UseRequestCulture(this IApplicationBuilder builder) 50 | { 51 | return builder.UseMiddleware(); 52 | } 53 | 54 | public static IApplicationBuilder UseRequestCulture(this IApplicationBuilder builder, RequestCultureOptions options) 55 | { 56 | return builder.UseMiddleware(Options.Create(options)); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Labs/Code/Lab4B/src/RequestCultureOptions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Globalization; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace Lab4B 9 | { 10 | public class RequestCultureOptions 11 | { 12 | public CultureInfo DefaultCulture { get; set; } 13 | 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Labs/Code/Lab4B/src/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Builder; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.AspNetCore.Http; 9 | using Microsoft.Extensions.Configuration; 10 | using Microsoft.Extensions.DependencyInjection; 11 | 12 | namespace Lab4B 13 | { 14 | public class Startup 15 | { 16 | private readonly IConfiguration _configuration; 17 | 18 | public Startup(IConfiguration configuration) 19 | { 20 | _configuration = configuration; 21 | } 22 | 23 | // This method gets called by the runtime. Use this method to add services to the container. 24 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 25 | public void ConfigureServices(IServiceCollection services) 26 | { 27 | services.Configure(options => 28 | { 29 | options.DefaultCulture = new CultureInfo(_configuration["culture"] ?? "en-GB"); 30 | }); 31 | } 32 | 33 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 34 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 35 | { 36 | app.Run(async (context) => 37 | { 38 | await context.Response.WriteAsync($"Hello {CultureInfo.CurrentCulture.DisplayName}"); 39 | }); 40 | 41 | app.UseRequestCulture(); 42 | } 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Labs/Code/Lab4B/src/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Labs/Code/Lab4B/src/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning" 5 | } 6 | }, 7 | "AllowedHosts": "*" 8 | } 9 | -------------------------------------------------------------------------------- /Labs/Code/Lab4B/src/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "culture": "en-US" 3 | } 4 | -------------------------------------------------------------------------------- /Labs/Code/Lab5A/Lab5A.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.28917.182 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{14917E84-0349-44AA-9E50-EECB3DAB9976}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab5A", "src\Lab5A\Lab5A.csproj", "{3B55DFDA-79ED-4938-903F-5ED05C76ACB7}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Debug|x64 = Debug|x64 14 | Debug|x86 = Debug|x86 15 | Release|Any CPU = Release|Any CPU 16 | Release|x64 = Release|x64 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x64.ActiveCfg = Debug|Any CPU 23 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x64.Build.0 = Debug|Any CPU 24 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x86.ActiveCfg = Debug|Any CPU 25 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x86.Build.0 = Debug|Any CPU 26 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x64.ActiveCfg = Release|Any CPU 29 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x64.Build.0 = Release|Any CPU 30 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x86.ActiveCfg = Release|Any CPU 31 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x86.Build.0 = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | GlobalSection(NestedProjects) = preSolution 37 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7} = {14917E84-0349-44AA-9E50-EECB3DAB9976} 38 | EndGlobalSection 39 | GlobalSection(ExtensibilityGlobals) = postSolution 40 | SolutionGuid = {BBA096C2-42FC-405B-BEC2-CB4972578542} 41 | EndGlobalSection 42 | EndGlobal 43 | -------------------------------------------------------------------------------- /Labs/Code/Lab5A/src/Lab5A/Lab5A.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netcoreapp3.1 4 | true 5 | 6 | 7 | -------------------------------------------------------------------------------- /Labs/Code/Lab5A/src/Lab5A/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Hosting; 3 | 4 | namespace Lab5A 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | CreateHostBuilder(args).Build().Run(); 11 | } 12 | 13 | public static IHostBuilder CreateHostBuilder(string[] args) => 14 | Host.CreateDefaultBuilder(args) 15 | .ConfigureWebHostDefaults(webBuilder => 16 | { 17 | webBuilder.UseUrls("http://localhost:8081") 18 | .UseStartup(); 19 | }); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Labs/Code/Lab5A/src/Lab5A/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:55740/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Lab4": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "launchUrl": "http://localhost:8081", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Production" 24 | }, 25 | "applicationUrl": "http://localhost:55741" 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Labs/Code/Lab5A/src/Lab5A/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.Extensions.Configuration; 5 | using Microsoft.Extensions.DependencyInjection; 6 | using Microsoft.Extensions.Hosting; 7 | using Microsoft.Extensions.Logging; 8 | 9 | namespace Lab5A 10 | { 11 | public class Startup 12 | { 13 | public IConfiguration Configuration { get; private set; } 14 | 15 | public Startup(IConfiguration configuration) 16 | { 17 | Configuration = configuration; 18 | } 19 | 20 | // This method gets called by the runtime. Use this method to add services to the container. 21 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 22 | public void ConfigureServices(IServiceCollection services) 23 | { 24 | } 25 | 26 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 27 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) 28 | { 29 | var startupLogger = loggerFactory.CreateLogger(); 30 | 31 | if (env.IsDevelopment()) 32 | { 33 | app.UseDeveloperExceptionPage(); 34 | } 35 | 36 | app.Run(async (context) => 37 | { 38 | //await context.Response.WriteAsync($"Hello World! {env.EnvironmentName}"); 39 | await context.Response.WriteAsync($"{Configuration["message"]}"); 40 | }); 41 | 42 | startupLogger.LogInformation("Application startup complete!"); 43 | startupLogger.LogCritical("This is a critical message"); 44 | startupLogger.LogDebug("This is a debug message"); 45 | startupLogger.LogTrace("This is a trace message"); 46 | startupLogger.LogWarning("This is a warning message"); 47 | startupLogger.LogError("This is an error message"); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Labs/Code/Lab5A/src/Lab5A/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning" 5 | }, 6 | "Console": { 7 | "LogLevel": { 8 | "Lab4.Startup": "Trace" 9 | } 10 | } 11 | }, 12 | "message": "Hello from configuration" 13 | } -------------------------------------------------------------------------------- /Labs/Code/Lab5A/src/Lab5A/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

Hello from ASP.NET Core!

9 | 10 | -------------------------------------------------------------------------------- /Labs/Code/Lab5B/Lab5B.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.28917.182 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{14917E84-0349-44AA-9E50-EECB3DAB9976}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab5B", "src\Lab5B\Lab5B.csproj", "{3B55DFDA-79ED-4938-903F-5ED05C76ACB7}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Debug|x64 = Debug|x64 14 | Debug|x86 = Debug|x86 15 | Release|Any CPU = Release|Any CPU 16 | Release|x64 = Release|x64 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x64.ActiveCfg = Debug|Any CPU 23 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x64.Build.0 = Debug|Any CPU 24 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x86.ActiveCfg = Debug|Any CPU 25 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x86.Build.0 = Debug|Any CPU 26 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x64.ActiveCfg = Release|Any CPU 29 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x64.Build.0 = Release|Any CPU 30 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x86.ActiveCfg = Release|Any CPU 31 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x86.Build.0 = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | GlobalSection(NestedProjects) = preSolution 37 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7} = {14917E84-0349-44AA-9E50-EECB3DAB9976} 38 | EndGlobalSection 39 | GlobalSection(ExtensibilityGlobals) = postSolution 40 | SolutionGuid = {9A62DE30-9367-4A8B-AF28-8747C3D645A0} 41 | EndGlobalSection 42 | EndGlobal 43 | -------------------------------------------------------------------------------- /Labs/Code/Lab5B/src/Lab5B/Lab5B.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netcoreapp3.1 4 | true 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Labs/Code/Lab5B/src/Lab5B/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Hosting; 3 | 4 | namespace Lab5B 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | CreateHostBuilder(args).Build().Run(); 11 | } 12 | 13 | public static IHostBuilder CreateHostBuilder(string[] args) => 14 | Host.CreateDefaultBuilder(args) 15 | .ConfigureWebHostDefaults(webBuilder => 16 | { 17 | webBuilder.UseUrls("http://localhost:8081") 18 | .UseStartup(); 19 | }); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Labs/Code/Lab5B/src/Lab5B/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:55740/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Lab4": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "launchUrl": "http://localhost:8081", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Production" 24 | }, 25 | "applicationUrl": "http://localhost:55741" 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Labs/Code/Lab5B/src/Lab5B/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.Extensions.Configuration; 5 | using Microsoft.Extensions.DependencyInjection; 6 | using Microsoft.Extensions.Logging; 7 | using Serilog; 8 | using System.IO; 9 | using Microsoft.Extensions.Hosting; 10 | 11 | namespace Lab5B 12 | { 13 | public class Startup 14 | { 15 | public IConfiguration Configuration { get; private set; } 16 | 17 | public Startup(IConfiguration configuration, IWebHostEnvironment env) 18 | { 19 | Configuration = configuration; 20 | 21 | var logFile = Path.Combine(env.ContentRootPath, "logfile.txt"); 22 | 23 | Log.Logger = new LoggerConfiguration() 24 | .WriteTo.File(logFile) 25 | .CreateLogger(); 26 | } 27 | 28 | // This method gets called by the runtime. Use this method to add services to the container. 29 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 30 | public void ConfigureServices(IServiceCollection services) 31 | { 32 | services.AddLogging(loggingBuilder => 33 | loggingBuilder.AddSerilog(dispose: true)); 34 | } 35 | 36 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 37 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) 38 | { 39 | var startupLogger = loggerFactory.CreateLogger(); 40 | 41 | if (env.IsDevelopment()) 42 | { 43 | app.UseDeveloperExceptionPage(); 44 | } 45 | 46 | app.Run(async (context) => 47 | { 48 | //await context.Response.WriteAsync($"Hello World! {env.EnvironmentName}"); 49 | await context.Response.WriteAsync($"{Configuration["message"]}"); 50 | }); 51 | 52 | startupLogger.LogInformation("Application startup complete!"); 53 | startupLogger.LogCritical("This is a critical message"); 54 | startupLogger.LogDebug("This is a debug message"); 55 | startupLogger.LogTrace("This is a trace message"); 56 | startupLogger.LogWarning("This is a warning message"); 57 | startupLogger.LogError("This is an error message"); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Labs/Code/Lab5B/src/Lab5B/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "message": "Hello from configuration" 3 | } -------------------------------------------------------------------------------- /Labs/Code/Lab5B/src/Lab5B/logfile.txt: -------------------------------------------------------------------------------- 1 | 2019-05-12 15:13:47.196 +02:00 [INF] Application startup complete! 2 | 2019-05-12 15:13:47.221 +02:00 [FTL] This is a critical message 3 | 2019-05-12 15:13:47.223 +02:00 [WRN] This is a warning message 4 | 2019-05-12 15:13:47.227 +02:00 [ERR] This is an error message 5 | 2019-06-27 13:15:14.589 -04:00 [INF] Application startup complete! 6 | 2019-06-27 13:15:14.615 -04:00 [FTL] This is a critical message 7 | 2019-06-27 13:15:14.618 -04:00 [WRN] This is a warning message 8 | 2019-06-27 13:15:14.620 -04:00 [ERR] This is an error message 9 | 2019-06-27 13:15:15.135 -04:00 [INF] Request starting HTTP/1.1 GET http://localhost:55740/ 10 | 2019-06-27 13:15:15.135 -04:00 [INF] Request starting HTTP/1.1 DEBUG http://localhost:55740/ 0 11 | 2019-06-27 13:15:15.206 -04:00 [INF] Request finished in 69.6093ms 200 12 | 2019-06-27 13:15:15.206 -04:00 [INF] Request finished in 66.8296ms 200 13 | 2020-04-04 16:49:47.548 +03:00 [INF] Application startup complete! 14 | 2020-04-04 16:49:47.578 +03:00 [FTL] This is a critical message 15 | 2020-04-04 16:49:47.580 +03:00 [WRN] This is a warning message 16 | 2020-04-04 16:49:47.582 +03:00 [ERR] This is an error message 17 | 2020-04-04 16:49:47.603 +03:00 [INF] Application started. Press Ctrl+C to shut down. 18 | 2020-04-04 16:49:47.612 +03:00 [INF] Hosting environment: Development 19 | 2020-04-04 16:49:47.621 +03:00 [INF] Content root path: D:\learning\misc\forks\aspnetcore-concepts-workshop\Labs\Code\Lab5B\src\Lab5B 20 | 2020-04-04 16:49:47.685 +03:00 [INF] Request starting HTTP/1.1 GET http://localhost:55740/ 21 | 2020-04-04 16:49:47.719 +03:00 [INF] Request finished in 38.0236ms 200 22 | -------------------------------------------------------------------------------- /Labs/Code/Lab5B/src/Lab5B/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

Hello from ASP.NET Core!

9 | 10 | -------------------------------------------------------------------------------- /Labs/Code/Lab5C/Lab5C.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.28917.182 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{14917E84-0349-44AA-9E50-EECB3DAB9976}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab5C", "src\Lab5C\Lab5C.csproj", "{3B55DFDA-79ED-4938-903F-5ED05C76ACB7}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Debug|x64 = Debug|x64 14 | Debug|x86 = Debug|x86 15 | Release|Any CPU = Release|Any CPU 16 | Release|x64 = Release|x64 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x64.ActiveCfg = Debug|Any CPU 23 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x64.Build.0 = Debug|Any CPU 24 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x86.ActiveCfg = Debug|Any CPU 25 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x86.Build.0 = Debug|Any CPU 26 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x64.ActiveCfg = Release|Any CPU 29 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x64.Build.0 = Release|Any CPU 30 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x86.ActiveCfg = Release|Any CPU 31 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x86.Build.0 = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | GlobalSection(NestedProjects) = preSolution 37 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7} = {14917E84-0349-44AA-9E50-EECB3DAB9976} 38 | EndGlobalSection 39 | GlobalSection(ExtensibilityGlobals) = postSolution 40 | SolutionGuid = {D0FF6FD3-9F7A-4474-9F50-C43D8662B02B} 41 | EndGlobalSection 42 | EndGlobal 43 | -------------------------------------------------------------------------------- /Labs/Code/Lab5C/src/Lab5C/Lab5C.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netcoreapp3.1 4 | true 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Labs/Code/Lab5C/src/Lab5C/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.Extensions.Hosting; 4 | 5 | namespace Lab5C 6 | { 7 | public class Program 8 | { 9 | public static void Main(string[] args) 10 | { 11 | CreateHostBuilder(args).Build().Run(); 12 | } 13 | 14 | public static IHostBuilder CreateHostBuilder(string[] args) => 15 | Host.CreateDefaultBuilder(args) 16 | .ConfigureWebHostDefaults(webBuilder => 17 | { 18 | webBuilder.UseUrls("http://localhost:8081") 19 | .UseStartup(); 20 | }); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Labs/Code/Lab5C/src/Lab5C/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:55740/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Production" 16 | } 17 | }, 18 | "Lab4": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "launchUrl": "http://localhost:8081", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | }, 25 | "applicationUrl": "http://localhost:55741" 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Labs/Code/Lab5C/src/Lab5C/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "message": "Hello from configuration" 3 | } -------------------------------------------------------------------------------- /Labs/Code/Lab5C/src/Lab5C/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

Hello from ASP.NET Core!

9 | 10 | -------------------------------------------------------------------------------- /Labs/Code/Lab5D/Lab5D.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26020.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{14917E84-0349-44AA-9E50-EECB3DAB9976}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab5D", "src\Lab5D\Lab5D.csproj", "{3B55DFDA-79ED-4938-903F-5ED05C76ACB7}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Debug|x64 = Debug|x64 14 | Debug|x86 = Debug|x86 15 | Release|Any CPU = Release|Any CPU 16 | Release|x64 = Release|x64 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x64.ActiveCfg = Debug|Any CPU 23 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x64.Build.0 = Debug|Any CPU 24 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x86.ActiveCfg = Debug|Any CPU 25 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Debug|x86.Build.0 = Debug|Any CPU 26 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x64.ActiveCfg = Release|Any CPU 29 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x64.Build.0 = Release|Any CPU 30 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x86.ActiveCfg = Release|Any CPU 31 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7}.Release|x86.Build.0 = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | GlobalSection(NestedProjects) = preSolution 37 | {3B55DFDA-79ED-4938-903F-5ED05C76ACB7} = {14917E84-0349-44AA-9E50-EECB3DAB9976} 38 | EndGlobalSection 39 | GlobalSection(ExtensibilityGlobals) = postSolution 40 | SolutionGuid = {BB0BD81B-B05D-435E-B267-6FF9F74E13D2} 41 | EndGlobalSection 42 | EndGlobal 43 | -------------------------------------------------------------------------------- /Labs/Code/Lab5D/src/Lab5D/Lab5D.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netcoreapp3.1 4 | true 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Labs/Code/Lab5D/src/Lab5D/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.Extensions.Hosting; 4 | 5 | namespace Lab5D 6 | { 7 | public class Program 8 | { 9 | public static void Main(string[] args) 10 | { 11 | CreateHostBuilder(args).Build().Run(); 12 | } 13 | 14 | public static IHostBuilder CreateHostBuilder(string[] args) => 15 | Host.CreateDefaultBuilder(args) 16 | .ConfigureWebHostDefaults(webBuilder => 17 | { 18 | webBuilder.UseUrls("http://localhost:8081") 19 | .UseStartup(); 20 | }); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Labs/Code/Lab5D/src/Lab5D/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:55740/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Production" 16 | } 17 | }, 18 | "Lab4": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "launchUrl": "http://localhost:8081", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Production" 24 | }, 25 | "applicationUrl": "http://localhost:55741" 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Labs/Code/Lab5D/src/Lab5D/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "message": "Hello from configuration" 3 | } -------------------------------------------------------------------------------- /Labs/Code/Lab5D/src/Lab5D/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

Hello from ASP.NET Core!

9 | 10 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/Lab6.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26020.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{54AB6CF6-FC25-4BAF-8F91-9916195FE671}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab6", "src\Lab6\Lab6.csproj", "{D084502B-3CB5-47A3-B0FA-52022639A728}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Debug|x64 = Debug|x64 14 | Debug|x86 = Debug|x86 15 | Release|Any CPU = Release|Any CPU 16 | Release|x64 = Release|x64 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {D084502B-3CB5-47A3-B0FA-52022639A728}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {D084502B-3CB5-47A3-B0FA-52022639A728}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {D084502B-3CB5-47A3-B0FA-52022639A728}.Debug|x64.ActiveCfg = Debug|Any CPU 23 | {D084502B-3CB5-47A3-B0FA-52022639A728}.Debug|x64.Build.0 = Debug|Any CPU 24 | {D084502B-3CB5-47A3-B0FA-52022639A728}.Debug|x86.ActiveCfg = Debug|Any CPU 25 | {D084502B-3CB5-47A3-B0FA-52022639A728}.Debug|x86.Build.0 = Debug|Any CPU 26 | {D084502B-3CB5-47A3-B0FA-52022639A728}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {D084502B-3CB5-47A3-B0FA-52022639A728}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {D084502B-3CB5-47A3-B0FA-52022639A728}.Release|x64.ActiveCfg = Release|Any CPU 29 | {D084502B-3CB5-47A3-B0FA-52022639A728}.Release|x64.Build.0 = Release|Any CPU 30 | {D084502B-3CB5-47A3-B0FA-52022639A728}.Release|x86.ActiveCfg = Release|Any CPU 31 | {D084502B-3CB5-47A3-B0FA-52022639A728}.Release|x86.Build.0 = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | GlobalSection(NestedProjects) = preSolution 37 | {D084502B-3CB5-47A3-B0FA-52022639A728} = {54AB6CF6-FC25-4BAF-8F91-9916195FE671} 38 | EndGlobalSection 39 | GlobalSection(ExtensibilityGlobals) = postSolution 40 | SolutionGuid = {94232308-7BC7-49C1-8B78-2D37B86AAA70} 41 | EndGlobalSection 42 | EndGlobal 43 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/Areas/Identity/Pages/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "/Views/Shared/_Layout.cshtml"; 3 | } 4 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | namespace Lab6.Controllers 8 | { 9 | public class HomeController : Controller 10 | { 11 | public IActionResult Index() 12 | { 13 | return View(); 14 | } 15 | 16 | public IActionResult About() 17 | { 18 | ViewData["Message"] = "Your application description page."; 19 | 20 | return View(); 21 | } 22 | 23 | public IActionResult Contact() 24 | { 25 | ViewData["Message"] = "Your contact page."; 26 | 27 | return View(); 28 | } 29 | 30 | public IActionResult Error() 31 | { 32 | return View(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/Data/ApplicationDbContext.cs: -------------------------------------------------------------------------------- 1 | using Lab6.Models; 2 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore; 4 | 5 | namespace Lab6.Data 6 | { 7 | public class ApplicationDbContext : IdentityDbContext 8 | { 9 | public ApplicationDbContext(DbContextOptions options) 10 | : base(options) 11 | { 12 | } 13 | 14 | protected override void OnModelCreating(ModelBuilder builder) 15 | { 16 | base.OnModelCreating(builder); 17 | // Customize the ASP.NET Identity model and override the defaults if needed. 18 | // For example, you can rename the ASP.NET Identity table names and more. 19 | // Add your customizations after calling base.OnModelCreating(builder); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/Lab6.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netcoreapp3.1 4 | true 5 | 6 | 7 | aspnet-Lab6-384ec857-d208-46c5-a05e-d0c01fc9a61b 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/Models/ApplicationUser.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | 3 | namespace Lab6.Models 4 | { 5 | // Add profile data for application users by adding properties to the ApplicationUser class 6 | public class ApplicationUser : IdentityUser 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.Extensions.Hosting; 4 | 5 | namespace Lab6 6 | { 7 | public class Program 8 | { 9 | public static void Main(string[] args) 10 | { 11 | CreateHostBuilder(args).Build().Run(); 12 | } 13 | 14 | public static IHostBuilder CreateHostBuilder(string[] args) => 15 | Host.CreateDefaultBuilder(args) 16 | .ConfigureWebHostDefaults(webBuilder => 17 | { 18 | webBuilder.UseStartup(); 19 | }); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:64359/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Lab6": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "http://localhost:64360" 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/RepeatTagHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Razor.TagHelpers; 2 | using System.Threading.Tasks; 3 | 4 | namespace Lab6 5 | { 6 | public class RepeatTagHelper : TagHelper 7 | { 8 | public int Count { get; set; } 9 | 10 | public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output) 11 | { 12 | output.TagName = null; 13 | 14 | for (int i = 0; i < Count; i++) 15 | { 16 | output.Content.AppendHtml(await output.GetChildContentAsync(useCachedResult: false)); 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/Services/IEmailSender.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace Lab6.Services 7 | { 8 | public interface IEmailSender 9 | { 10 | Task SendEmailAsync(string email, string subject, string message); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/Services/ISmsSender.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace Lab6.Services 7 | { 8 | public interface ISmsSender 9 | { 10 | Task SendSmsAsync(string number, string message); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/Services/MessageServices.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace Lab6.Services 7 | { 8 | // This class is used by the application to send Email and SMS 9 | // when you turn on two-factor authentication in ASP.NET Identity. 10 | // For more details see this link http://go.microsoft.com/fwlink/?LinkID=532713 11 | public class AuthMessageSender : IEmailSender, ISmsSender 12 | { 13 | public Task SendEmailAsync(string email, string subject, string message) 14 | { 15 | // Plug in your email service here to send an email. 16 | return Task.FromResult(0); 17 | } 18 | 19 | public Task SendSmsAsync(string number, string message) 20 | { 21 | // Plug in your SMS service here to send a text message. 22 | return Task.FromResult(0); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/Views/Home/About.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "About"; 3 | } 4 |

@ViewData["Title"].

5 |

@ViewData["Message"]

6 | 7 |

Use this area to provide additional information.

8 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/Views/Home/Contact.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Contact"; 3 | } 4 |

@ViewData["Title"].

5 |

@ViewData["Message"]

6 | 7 |
8 | One Microsoft Way
9 | Redmond, WA 98052-6399
10 | P: 11 | 425.555.0100 12 |
13 | 14 |
15 | Support: Support@example.com
16 | Marketing: Marketing@example.com 17 |
18 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Error"; 3 | } 4 | 5 |

Error.

6 |

An error occurred while processing your request.

7 | 8 |

Development Mode

9 |

10 | Swapping to Development environment will display more detailed information about the error that occurred. 11 |

12 |

13 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. 14 |

15 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/Views/Shared/_LoginPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Identity 2 | @using Lab6.Models 3 | 4 | @inject SignInManager SignInManager 5 | @inject UserManager UserManager 6 | 7 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using Lab6 2 | @using Lab6.Models 3 | @using Microsoft.AspNetCore.Identity 4 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 5 | @addTagHelper *, Lab6 -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-Lab6-fb1b664f-9f81-4880-9063-c3543ec80118;Trusted_Connection=True;MultipleActiveResultSets=true" 4 | }, 5 | "Logging": { 6 | "IncludeScopes": false, 7 | "LogLevel": { 8 | "Default": "Debug", 9 | "System": "Information", 10 | "Microsoft": "Information" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/bundleconfig.json: -------------------------------------------------------------------------------- 1 | // Configure bundling and minification for the project. 2 | // More info at https://go.microsoft.com/fwlink/?LinkId=808241 3 | [ 4 | { 5 | "outputFileName": "wwwroot/css/site.min.css", 6 | // An array of relative input file paths. Globbing patterns supported 7 | "inputFiles": [ 8 | "wwwroot/css/site.css" 9 | ] 10 | }, 11 | { 12 | "outputFileName": "wwwroot/js/site.min.js", 13 | "inputFiles": [ 14 | "wwwroot/js/site.js" 15 | ], 16 | // Optionally specify minification options 17 | "minify": { 18 | "enabled": true, 19 | "renameLocals": true 20 | }, 21 | // Optionally generate .map file 22 | "sourceMap": false 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/libman.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "defaultProvider": "cdnjs", 4 | "libraries": [ 5 | { 6 | "library": "jquery@3.4.1", 7 | "destination": "wwwroot/lib/jquery/" 8 | }, 9 | { 10 | "library": "jquery-validation-unobtrusive@3.2.11", 11 | "destination": "wwwroot/lib/jquery-validation-unobtrusive/" 12 | }, 13 | { 14 | "provider": "unpkg", 15 | "library": "bootstrap@4.3.1", 16 | "destination": "wwwroot/lib/bootstrap/" 17 | }, 18 | { 19 | "provider": "unpkg", 20 | "library": "jquery-validation@1.19.0", 21 | "destination": "wwwroot/lib/jquery-validation/" 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Sticky footer styles 11 | -------------------------------------------------- */ 12 | html { 13 | font-size: 14px; 14 | } 15 | 16 | @media (min-width: 768px) { 17 | html { 18 | font-size: 16px; 19 | } 20 | } 21 | 22 | .border-top { 23 | border-top: 1px solid #e5e5e5; 24 | } 25 | 26 | .border-bottom { 27 | border-bottom: 1px solid #e5e5e5; 28 | } 29 | 30 | .box-shadow { 31 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 32 | } 33 | 34 | button.accept-policy { 35 | font-size: 1rem; 36 | line-height: inherit; 37 | } 38 | 39 | /* Sticky footer styles 40 | -------------------------------------------------- */ 41 | html { 42 | position: relative; 43 | min-height: 100%; 44 | } 45 | 46 | body { 47 | /* Margin bottom by footer height */ 48 | margin-bottom: 60px; 49 | } 50 | 51 | .footer { 52 | position: absolute; 53 | bottom: 0; 54 | width: 100%; 55 | white-space: nowrap; 56 | /* Set the fixed height of the footer here */ 57 | height: 60px; 58 | line-height: 60px; /* Vertically center the text there */ 59 | } 60 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/wwwroot/css/site.min.css: -------------------------------------------------------------------------------- 1 | body{padding-top:50px;padding-bottom:20px}.body-content{padding-left:15px;padding-right:15px}input,select,textarea{max-width:280px}.carousel-caption p{font-size:20px;line-height:1.4}.btn-bracketed::before{display:inline-block;content:"[";padding-right:.5em}.btn-bracketed::after{display:inline-block;content:"]";padding-left:.5em}.carousel-inner .item img[src$=".svg"]{width:100%}@media screen and (max-width:767px){.carousel-caption{display:none}} -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-concepts-workshop/HEAD/Labs/Code/Lab6/src/Lab6/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Write your Javascript code. 2 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/wwwroot/js/site.min.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2019 Twitter, Inc. 4 | Copyright (c) 2011-2019 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Labs/Code/Lab6/src/Lab6/wwwroot/lib/jquery-validation/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation", 3 | "title": "jQuery Validation Plugin", 4 | "description": "Client-side form validation made easy", 5 | "version": "1.19.0", 6 | "homepage": "https://jqueryvalidation.org/", 7 | "license": "MIT", 8 | "author": { 9 | "name": "Jörn Zaefferer", 10 | "email": "joern.zaefferer@gmail.com", 11 | "url": "http://bassistance.de" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "git://github.com/jquery-validation/jquery-validation.git" 16 | }, 17 | "bugs": { 18 | "url": "https://github.com/jquery-validation/jquery-validation/issues" 19 | }, 20 | "licenses": [ 21 | { 22 | "type": "MIT", 23 | "url": "https://www.opensource.org/licenses/MIT" 24 | } 25 | ], 26 | "scripts": { 27 | "test": "grunt", 28 | "prepublish": "grunt" 29 | }, 30 | "files": [ 31 | "dist/localization/", 32 | "dist/additional-methods.js", 33 | "dist/additional-methods.min.js", 34 | "dist/jquery.validate.js", 35 | "dist/jquery.validate.min.js" 36 | ], 37 | "main": "dist/jquery.validate.js", 38 | "dependencies": { 39 | "jquery": "^1.7 || ^2.0 || ^3.1" 40 | }, 41 | "devDependencies": { 42 | "commitplease": "2.3.1", 43 | "grunt": "1.0.1", 44 | "grunt-contrib-compress": "1.2.0", 45 | "grunt-contrib-concat": "1.0.1", 46 | "grunt-contrib-copy": "1.0.0", 47 | "grunt-contrib-jshint": "1.0.0", 48 | "grunt-contrib-qunit": "1.2.0", 49 | "grunt-contrib-uglify": "1.0.1", 50 | "grunt-contrib-watch": "1.0.0", 51 | "grunt-jscs": "2.8.0", 52 | "grunt-sri": "0.2.0", 53 | "grunt-text-replace": "0.4.0", 54 | "qunitjs": "2.3.3" 55 | }, 56 | "keywords": [ 57 | "jquery", 58 | "jquery-plugin", 59 | "forms", 60 | "validation", 61 | "validate" 62 | ] 63 | } 64 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /dist-server 6 | /tmp 7 | /out-tsc 8 | 9 | # dependencies 10 | /node_modules 11 | 12 | # IDEs and editors 13 | /.idea 14 | .project 15 | .classpath 16 | .c9/ 17 | *.launch 18 | .settings/ 19 | *.sublime-workspace 20 | 21 | # IDE - VSCode 22 | .vscode/* 23 | !.vscode/settings.json 24 | !.vscode/tasks.json 25 | !.vscode/launch.json 26 | !.vscode/extensions.json 27 | 28 | # misc 29 | /.sass-cache 30 | /connect.lock 31 | /coverage 32 | /libpeerconnection.log 33 | npm-debug.log 34 | yarn-error.log 35 | testem.log 36 | /typings 37 | 38 | # System Files 39 | .DS_Store 40 | Thumbs.db 41 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/README.md: -------------------------------------------------------------------------------- 1 | # Lab7 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 6.0.0. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 28 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './src/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: require('path').join(__dirname, './tsconfig.e2e.json') 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should display welcome message', () => { 11 | page.navigateTo(); 12 | expect(page.getMainHeading()).toEqual('Hello, world!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getMainHeading() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Lab7", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "build:ssr": "ng run Lab7:server:dev", 9 | "test": "ng test", 10 | "lint": "ng lint", 11 | "e2e": "ng e2e" 12 | }, 13 | "private": true, 14 | "dependencies": { 15 | "@angular/animations": "6.1.10", 16 | "@angular/common": "6.1.10", 17 | "@angular/compiler": "6.1.10", 18 | "@angular/core": "6.1.10", 19 | "@angular/forms": "6.1.10", 20 | "@angular/http": "6.1.10", 21 | "@angular/platform-browser": "6.1.10", 22 | "@angular/platform-browser-dynamic": "6.1.10", 23 | "@angular/platform-server": "6.1.10", 24 | "@angular/router": "6.1.10", 25 | "@nguniversal/module-map-ngfactory-loader": "6.0.0", 26 | "core-js": "^2.5.4", 27 | "rxjs": "^6.0.0", 28 | "zone.js": "^0.8.26", 29 | "aspnet-prerendering": "^3.0.1", 30 | "bootstrap": "^4.3.1", 31 | "jquery": "3.5.0", 32 | "popper.js": "^1.14.3" 33 | }, 34 | "devDependencies": { 35 | "@angular-devkit/build-angular": "~0.6.0", 36 | "@angular/cli": "~6.0.0", 37 | "@angular/compiler-cli": "6.1.10", 38 | "@angular/language-service": "^6.0.0", 39 | "@types/jasmine": "~2.8.6", 40 | "@types/jasminewd2": "~2.0.3", 41 | "@types/node": "~8.9.4", 42 | "codelyzer": "~4.2.1", 43 | "jasmine-core": "~2.99.1", 44 | "jasmine-spec-reporter": "~4.2.1", 45 | "karma": "^3.0.0", 46 | "karma-chrome-launcher": "~2.2.0", 47 | "karma-coverage-istanbul-reporter": "~1.4.2", 48 | "karma-jasmine": "~1.1.1", 49 | "karma-jasmine-html-reporter": "^0.2.2", 50 | "typescript": "~2.7.2" 51 | }, 52 | "optionalDependencies": { 53 | "node-sass": "^4.9.3", 54 | "protractor": "~5.4.0", 55 | "ts-node": "~5.0.1", 56 | "tslint": "~5.9.1" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/app/app.component.css: -------------------------------------------------------------------------------- 1 | @media (max-width: 767px) { 2 | /* On small screens, the nav menu spans the full width of the screen. Leave a space for it. */ 3 | .body-content { 4 | padding-top: 50px; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
6 | 7 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.css'] 7 | }) 8 | export class AppComponent { 9 | title = 'app'; 10 | } 11 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { HttpClientModule } from '@angular/common/http'; 5 | import { RouterModule } from '@angular/router'; 6 | 7 | import { AppComponent } from './app.component'; 8 | import { NavMenuComponent } from './nav-menu/nav-menu.component'; 9 | import { HomeComponent } from './home/home.component'; 10 | import { CounterComponent } from './counter/counter.component'; 11 | import { FetchDataComponent } from './fetch-data/fetch-data.component'; 12 | 13 | @NgModule({ 14 | declarations: [ 15 | AppComponent, 16 | NavMenuComponent, 17 | HomeComponent, 18 | CounterComponent, 19 | FetchDataComponent 20 | ], 21 | imports: [ 22 | BrowserModule.withServerTransition({ appId: 'ng-cli-universal' }), 23 | HttpClientModule, 24 | FormsModule, 25 | RouterModule.forRoot([ 26 | { path: '', component: HomeComponent, pathMatch: 'full' }, 27 | { path: 'counter', component: CounterComponent }, 28 | { path: 'fetch-data', component: FetchDataComponent }, 29 | ]) 30 | ], 31 | providers: [], 32 | bootstrap: [AppComponent] 33 | }) 34 | export class AppModule { } 35 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/app/app.server.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { ServerModule } from '@angular/platform-server'; 3 | import { ModuleMapLoaderModule } from '@nguniversal/module-map-ngfactory-loader'; 4 | import { AppComponent } from './app.component'; 5 | import { AppModule } from './app.module'; 6 | 7 | @NgModule({ 8 | imports: [AppModule, ServerModule, ModuleMapLoaderModule], 9 | bootstrap: [AppComponent] 10 | }) 11 | export class AppServerModule { } 12 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/app/counter/counter.component.html: -------------------------------------------------------------------------------- 1 |

Counter

2 | 3 |

This is a simple example of an Angular component.

4 | 5 |

Current count: {{ currentCount }}

6 | 7 | 8 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/app/counter/counter.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { CounterComponent } from './counter.component'; 4 | 5 | describe('CounterComponent', () => { 6 | let component: CounterComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ CounterComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(CounterComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should display a title', async(() => { 23 | const titleText = fixture.nativeElement.querySelector('h1').textContent; 24 | expect(titleText).toEqual('Counter'); 25 | })); 26 | 27 | it('should start with count 0, then increments by 1 when clicked', async(() => { 28 | const countElement = fixture.nativeElement.querySelector('strong'); 29 | expect(countElement.textContent).toEqual('0'); 30 | 31 | const incrementButton = fixture.nativeElement.querySelector('button'); 32 | incrementButton.click(); 33 | fixture.detectChanges(); 34 | expect(countElement.textContent).toEqual('1'); 35 | })); 36 | }); 37 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/app/counter/counter.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-counter-component', 5 | templateUrl: './counter.component.html' 6 | }) 7 | export class CounterComponent { 8 | public currentCount = 0; 9 | 10 | public incrementCounter() { 11 | this.currentCount+=10; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/app/fetch-data/fetch-data.component.html: -------------------------------------------------------------------------------- 1 |

Weather forecast

2 | 3 |

This component demonstrates fetching data from the server.

4 | 5 |

Loading...

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
DateTemp. (C)Temp. (F)Summary
{{ forecast.dateFormatted }}{{ forecast.temperatureC }}{{ forecast.temperatureF }}{{ forecast.summary }}
25 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/app/fetch-data/fetch-data.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Inject } from '@angular/core'; 2 | import { HttpClient } from '@angular/common/http'; 3 | 4 | @Component({ 5 | selector: 'app-fetch-data', 6 | templateUrl: './fetch-data.component.html' 7 | }) 8 | export class FetchDataComponent { 9 | public forecasts: WeatherForecast[]; 10 | 11 | constructor(http: HttpClient, @Inject('BASE_URL') baseUrl: string) { 12 | http.get(baseUrl + 'api/SampleData/WeatherForecasts').subscribe(result => { 13 | this.forecasts = result; 14 | }, error => console.error(error)); 15 | } 16 | } 17 | 18 | interface WeatherForecast { 19 | dateFormatted: string; 20 | temperatureC: number; 21 | temperatureF: number; 22 | summary: string; 23 | } 24 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/app/home/home.component.html: -------------------------------------------------------------------------------- 1 |

Hello, world!

2 |

Welcome to your new single-page application, built with:

3 | 8 |

To help you get started, we've also set up:

9 |
    10 |
  • Client-side navigation. For example, click Counter then Back to return here.
  • 11 |
  • Angular CLI integration. In development mode, there's no need to run ng serve. It runs in the background automatically, so your client-side resources are dynamically built on demand and the page refreshes when you modify any file.
  • 12 |
  • Efficient production builds. In production mode, development-time features are disabled, and your dotnet publish configuration automatically invokes ng build to produce minified, ahead-of-time compiled JavaScript files.
  • 13 |
14 |

The ClientApp subdirectory is a standard Angular CLI application. If you open a command prompt in that directory, you can run any ng command (e.g., ng test), or use npm to install extra packages into it.

15 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/app/home/home.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-home', 5 | templateUrl: './home.component.html', 6 | }) 7 | export class HomeComponent { 8 | } 9 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/app/nav-menu/nav-menu.component.css: -------------------------------------------------------------------------------- 1 | a.navbar-brand { 2 | white-space: normal; 3 | text-align: center; 4 | word-break: break-all; 5 | } 6 | 7 | html { 8 | font-size: 14px; 9 | } 10 | @media (min-width: 768px) { 11 | html { 12 | font-size: 16px; 13 | } 14 | } 15 | 16 | .box-shadow { 17 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 18 | } 19 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/app/nav-menu/nav-menu.component.html: -------------------------------------------------------------------------------- 1 |
2 | 24 |
25 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/app/nav-menu/nav-menu.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-nav-menu', 5 | templateUrl: './nav-menu.component.html', 6 | styleUrls: ['./nav-menu.component.css'] 7 | }) 8 | export class NavMenuComponent { 9 | isExpanded = false; 10 | 11 | collapse() { 12 | this.isExpanded = false; 13 | } 14 | 15 | toggle() { 16 | this.isExpanded = !this.isExpanded; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/browserslist: -------------------------------------------------------------------------------- 1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | # For IE 9-11 support, please uncomment the last line of the file and adjust as needed 5 | > 0.5% 6 | last 2 versions 7 | Firefox ESR 8 | not dead 9 | # IE 9-11 -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * In development mode, to ignore zone related error stack frames such as 11 | * `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can 12 | * import the following file, but please comment it out in production mode 13 | * because it will have performance impact when throw error 14 | */ 15 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 16 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Lab7 6 | 7 | 8 | 9 | 10 | 11 | 12 | Loading... 13 | 14 | 15 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage'), 20 | reports: ['html', 'lcovonly'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | export function getBaseUrl() { 8 | return document.getElementsByTagName('base')[0].href; 9 | } 10 | 11 | const providers = [ 12 | { provide: 'BASE_URL', useFactory: getBaseUrl, deps: [] } 13 | ]; 14 | 15 | if (environment.production) { 16 | enableProdMode(); 17 | } 18 | 19 | platformBrowserDynamic(providers).bootstrapModule(AppModule) 20 | .catch(err => console.log(err)); 21 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "es2015", 6 | "types": [] 7 | }, 8 | "exclude": [ 9 | "src/test.ts", 10 | "**/*.spec.ts" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/tsconfig.server.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "commonjs" 5 | }, 6 | "angularCompilerOptions": { 7 | "entryModule": "app/app.server.module#AppServerModule" 8 | } 9 | } -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "module": "commonjs", 6 | "types": [ 7 | "jasmine", 8 | "node" 9 | ] 10 | }, 11 | "files": [ 12 | "test.ts", 13 | "polyfills.ts" 14 | ], 15 | "include": [ 16 | "**/*.spec.ts", 17 | "**/*.d.ts" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/src/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "app", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "app", 14 | "kebab-case" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/ClientApp/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "moduleResolution": "node", 9 | "emitDecoratorMetadata": true, 10 | "experimentalDecorators": true, 11 | "target": "es5", 12 | "typeRoots": [ 13 | "node_modules/@types" 14 | ], 15 | "lib": [ 16 | "es2017", 17 | "dom" 18 | ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/Controllers/SampleDataController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | namespace Lab7.Controllers 8 | { 9 | [Route("api/[controller]")] 10 | public class SampleDataController : Controller 11 | { 12 | private static string[] Summaries = new[] 13 | { 14 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 15 | }; 16 | 17 | [HttpGet("[action]")] 18 | public IEnumerable WeatherForecasts() 19 | { 20 | var rng = new Random(); 21 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast 22 | { 23 | DateFormatted = DateTime.Now.AddDays(index).ToString("d"), 24 | TemperatureC = rng.Next(-20, 55), 25 | Summary = Summaries[rng.Next(Summaries.Length)] 26 | }); 27 | } 28 | 29 | public class WeatherForecast 30 | { 31 | public string DateFormatted { get; set; } 32 | public int TemperatureC { get; set; } 33 | public string Summary { get; set; } 34 | 35 | public int TemperatureF 36 | { 37 | get 38 | { 39 | return 32 + (int)(TemperatureC / 0.5556); 40 | } 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/Lab7.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.2 5 | true 6 | Latest 7 | false 8 | ClientApp\ 9 | $(DefaultItemExcludes);$(SpaRoot)node_modules\** 10 | 11 | 12 | false 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | %(DistFiles.Identity) 49 | PreserveNewest 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model ErrorModel 3 | @{ 4 | ViewData["Title"] = "Error"; 5 | } 6 | 7 |

Error.

8 |

An error occurred while processing your request.

9 | 10 | @if (Model.ShowRequestId) 11 | { 12 |

13 | Request ID: @Model.RequestId 14 |

15 | } 16 | 17 |

Development Mode

18 |

19 | Swapping to the Development environment displays detailed information about the error that occurred. 20 |

21 |

22 | The Development environment shouldn't be enabled for deployed applications. 23 | It can result in displaying sensitive information from exceptions to end users. 24 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 25 | and restarting the app. 26 |

27 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.AspNetCore.Mvc.RazorPages; 8 | 9 | namespace Lab7.Pages 10 | { 11 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 12 | public class ErrorModel : PageModel 13 | { 14 | public string RequestId { get; set; } 15 | 16 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 17 | 18 | public void OnGet() 19 | { 20 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/Pages/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using Lab7 2 | @namespace Lab7.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace Lab7 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | CreateWebHostBuilder(args).Build().Run(); 18 | } 19 | 20 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 21 | WebHost.CreateDefaultBuilder(args) 22 | .UseStartup(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:46858", 7 | "sslPort": 44396 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Lab7": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Labs/Code/Lab7/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.AspNetCore.HttpsPolicy; 4 | using Microsoft.AspNetCore.Mvc; 5 | using Microsoft.AspNetCore.SpaServices.AngularCli; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.DependencyInjection; 8 | 9 | namespace Lab7 10 | { 11 | public class Startup 12 | { 13 | public Startup(IConfiguration configuration) 14 | { 15 | Configuration = configuration; 16 | } 17 | 18 | public IConfiguration Configuration { get; } 19 | 20 | // This method gets called by the runtime. Use this method to add services to the container. 21 | public void ConfigureServices(IServiceCollection services) 22 | { 23 | services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); 24 | 25 | // In production, the Angular files will be served from this directory 26 | services.AddSpaStaticFiles(configuration => 27 | { 28 | configuration.RootPath = "ClientApp/dist"; 29 | }); 30 | } 31 | 32 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 33 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 34 | { 35 | if (env.IsDevelopment()) 36 | { 37 | app.UseDeveloperExceptionPage(); 38 | } 39 | else 40 | { 41 | app.UseExceptionHandler("/Error"); 42 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 43 | app.UseHsts(); 44 | } 45 | 46 | app.UseHttpsRedirection(); 47 | app.UseStaticFiles(); 48 | app.UseSpaStaticFiles(); 49 | 50 | app.UseMvc(routes => 51 | { 52 | routes.MapRoute( 53 | name: "default", 54 | template: "{controller}/{action=Index}/{id?}"); 55 | }); 56 | 57 | app.UseSpa(spa => 58 | { 59 | // To learn more about options for serving an Angular SPA from ASP.NET Core, 60 | // see https://go.microsoft.com/fwlink/?linkid=864501 61 | 62 | spa.Options.SourcePath = "ClientApp"; 63 | 64 | if (env.IsDevelopment()) 65 | { 66 | spa.UseAngularCliServer(npmScript: "start"); 67 | } 68 | }); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning" 5 | } 6 | }, 7 | "AllowedHosts": "*" 8 | } 9 | -------------------------------------------------------------------------------- /Labs/Code/Lab7/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-concepts-workshop/HEAD/Labs/Code/Lab7/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Labs/Code/Lab8/Lab8.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26020.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{31993304-902E-437F-A24B-2BC6F17061F3}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab8", "src\Lab8\Lab8.csproj", "{9D59F770-EF3E-427E-A1C0-564306372914}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Debug|x64 = Debug|x64 14 | Debug|x86 = Debug|x86 15 | Release|Any CPU = Release|Any CPU 16 | Release|x64 = Release|x64 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {9D59F770-EF3E-427E-A1C0-564306372914}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {9D59F770-EF3E-427E-A1C0-564306372914}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {9D59F770-EF3E-427E-A1C0-564306372914}.Debug|x64.ActiveCfg = Debug|Any CPU 23 | {9D59F770-EF3E-427E-A1C0-564306372914}.Debug|x64.Build.0 = Debug|Any CPU 24 | {9D59F770-EF3E-427E-A1C0-564306372914}.Debug|x86.ActiveCfg = Debug|Any CPU 25 | {9D59F770-EF3E-427E-A1C0-564306372914}.Debug|x86.Build.0 = Debug|Any CPU 26 | {9D59F770-EF3E-427E-A1C0-564306372914}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {9D59F770-EF3E-427E-A1C0-564306372914}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {9D59F770-EF3E-427E-A1C0-564306372914}.Release|x64.ActiveCfg = Release|Any CPU 29 | {9D59F770-EF3E-427E-A1C0-564306372914}.Release|x64.Build.0 = Release|Any CPU 30 | {9D59F770-EF3E-427E-A1C0-564306372914}.Release|x86.ActiveCfg = Release|Any CPU 31 | {9D59F770-EF3E-427E-A1C0-564306372914}.Release|x86.Build.0 = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | GlobalSection(NestedProjects) = preSolution 37 | {9D59F770-EF3E-427E-A1C0-564306372914} = {31993304-902E-437F-A24B-2BC6F17061F3} 38 | EndGlobalSection 39 | GlobalSection(ExtensibilityGlobals) = postSolution 40 | SolutionGuid = {04923B84-91B4-462D-88A2-C5072949D882} 41 | EndGlobalSection 42 | EndGlobal 43 | -------------------------------------------------------------------------------- /Labs/Code/Lab8/src/Lab8/Controllers/ProductsController.cs: -------------------------------------------------------------------------------- 1 | using Lab8.Models; 2 | using Microsoft.AspNetCore.Mvc; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | namespace Lab8.Controllers 7 | { 8 | [Route("/api/[controller]")] 9 | // [Produces("application/json")] 10 | public class ProductsController : ControllerBase 11 | { 12 | private static List _products = new List(new[] { 13 | new Product() { Id = 1, Name = "Computer" }, 14 | new Product() { Id = 2, Name = "Radio" }, 15 | new Product() { Id = 3, Name = "Apple" }, 16 | }); 17 | 18 | [HttpGet] 19 | public IEnumerable Get() => _products; 20 | 21 | [HttpGet("{id}")] 22 | public IActionResult Get(int id) 23 | { 24 | var product = _products.SingleOrDefault(p => p.Id == id); 25 | 26 | if (product == null) 27 | { 28 | return NotFound(); 29 | } 30 | 31 | return Ok(product); 32 | } 33 | 34 | [HttpPost] 35 | public IActionResult Post([FromBody]Product product) 36 | { 37 | if (!ModelState.IsValid) 38 | { 39 | return BadRequest(ModelState); 40 | } 41 | 42 | _products.Add(product); 43 | return CreatedAtAction(nameof(Get), new { id = product.Id }, product); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Labs/Code/Lab8/src/Lab8/Lab8.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netcoreapp3.1 4 | true 5 | 6 | -------------------------------------------------------------------------------- /Labs/Code/Lab8/src/Lab8/Models/Product.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace Lab8.Models 8 | { 9 | public class Product 10 | { 11 | public int Id { get; set; } 12 | 13 | [Required] 14 | public string Name { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Labs/Code/Lab8/src/Lab8/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore; 2 | using Microsoft.AspNetCore.Hosting; 3 | 4 | namespace Lab8 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | CreateWebHostBuilder(args).Build().Run(); 11 | } 12 | 13 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 14 | WebHost.CreateDefaultBuilder(args) 15 | .UseStartup(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Labs/Code/Lab8/src/Lab8/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:51418/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Lab8": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "http://localhost:51419" 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Labs/Code/Lab8/src/Lab8/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Hosting; 5 | 6 | namespace Lab8 7 | { 8 | public class Startup 9 | { 10 | // This method gets called by the runtime. Use this method to add services to the container. 11 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 12 | public void ConfigureServices(IServiceCollection services) 13 | { 14 | services.AddControllers(options => 15 | { 16 | options.RespectBrowserAcceptHeader = true; 17 | }) 18 | .AddXmlSerializerFormatters(); 19 | } 20 | 21 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 22 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 23 | { 24 | if (env.IsDevelopment()) 25 | { 26 | app.UseDeveloperExceptionPage(); 27 | } 28 | 29 | app.UseRouting(); 30 | app.UseEndpoints(endpoints => 31 | { 32 | endpoints.MapControllerRoute( 33 | name: "default", 34 | pattern: "{controller}/{action}/{id?}", 35 | defaults: new { controller = "Home", action = "Index" } 36 | ); 37 | }); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Labs/Images/install-nuget-package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-concepts-workshop/HEAD/Labs/Images/install-nuget-package.png -------------------------------------------------------------------------------- /Labs/Images/new-webapp-individual-accounts.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-concepts-workshop/HEAD/Labs/Images/new-webapp-individual-accounts.PNG -------------------------------------------------------------------------------- /Labs/Images/run-with-kestrel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-concepts-workshop/HEAD/Labs/Images/run-with-kestrel.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # ASP.NET Core Workshop 3 | 4 | This workshop covers various concepts of ASP.NET Core: 5 | 6 | |Lab|Description|Prerequisites| 7 | --|--|--| 8 | |[.NET Core SDK](Labs\1.%20Introduction%20to%20the%20.NET%20Core%20SDK.md) | Convert a .NET Core Console Application into a ASP.NET Core Web Application. | 9 | |[MVC Applications](Labs\2.%20MVC%20Applications%20with%20ASP.NET%20Core.md) | Create an .NET Core MVC App and explore routing. 10 | |[Startup, Hosting, and Middleware](Labs\3.%20Startup,%20Hosting%20and%20Middleware.md) | Explore the different configuration options available for a ASP.NET Core application. 11 | |[Dependency Injections and Unit Testing](Labs\4.%20Dependency%20Injection%20&%20Unit%20Testing.md) | Use Dependency Injection (DI) to register and resolve application services. 12 | |[Building Middleware](Labs\4.5%20Building%20Middleware.md) | Create a middleware pipline to set the current [culture](https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo) of a ASP.NET Core App. |[MVC Applications](Labs\2.%20MVC%20Applications%20with%20ASP.NET%20Core.md) (optional) 13 | |[Logging and Diagnostics](Labs\5.%20Logging%20and%20Diagnostics.md) | Create logs, then filter them. Explore diagnostics middleware. | [MVC Applications](Labs\2.%20MVC%20Applications%20with%20ASP.NET%20Core.md) 14 | |[Razor Tag Helpers](Labs\6.%20Working%20with%20Razor%20Tag%20Helpers.md) | Create a custom Tag Helper. | 15 | |[Single Page Applications (SPA)](Labs\7.%20Single%20Page%20Applications.md) | Experiment with hot module reloading with an ASP.NET Core Angular App | .. 16 | |[Building a Single Page Application with Angular](Labs\7.5%20App%20building%20-%20Attendee%20List.md) | Using what you've learned so far, build a simple application for managing a list of course attendees. | All prior labs. 17 | |[APIs with MVC Core](Labs\8.%20APIs%20with%20MVC%20Core.md) | Build a simple API with MVC Core. | 18 | |[Hosting & Deployment](Labs\8.1%20Hosting%20&%20Deployment.md)| Deploy your ASP.NET Core App to Azure. | [APIs with MVC Core](Labs\8.%20APIs%20with%20MVC%20Core.md) 19 | 20 | ## Getting Started 21 | 22 | ### Installation 23 | 24 | - [.NET Core SDK 2.2](https://dotnet.microsoft.com/download) 25 | - [Visual Studio Code](https://visualstudio.microsoft.com/downloads/) 26 | - [Visual Studio 2019](https://visualstudio.microsoft.com/downloads/) 27 | 28 | In the Visual Studio Installer, install the following workloads: 29 | 30 | - ASP.NET and web development 31 | - .NET Core cross-platform development 32 | - Azure development (Only required for [Lab 8.1](Labs\8.1%20Hosting%20&%20Deployment.md)) 33 | -------------------------------------------------------------------------------- /Slides/Intro to ASPNET Core.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-concepts-workshop/HEAD/Slides/Intro to ASPNET Core.pptx -------------------------------------------------------------------------------- /Slides/MVC Applications with ASP.NET Core.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-concepts-workshop/HEAD/Slides/MVC Applications with ASP.NET Core.pptx -------------------------------------------------------------------------------- /Slides/Single Page Applications.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-concepts-workshop/HEAD/Slides/Single Page Applications.pptx -------------------------------------------------------------------------------- /notes/1. Intro to .NET Core: -------------------------------------------------------------------------------- 1 | a. .NET Core Overview 2 | i. What and why 3 | ii. Acquisition 4 | 1) http://dot.net -> https://www.microsoft.com/net/download/core#/current 5 | 2) Windows SDK (Installer) 6 | 3) Visual Studio 2019 Tools (Preview 4) 7 | iii. Dotnet driver (dotnet.exe) 8 | iv. Dotnet CLI commands 9 | 1) Dotnet new 10 | 2) Dotnet restore 11 | 3) Dotnet run 12 | 4) Dotnet myapp.dll 13 | 5) Dotnet publish 14 | v. Microsoft.NETCore.App meta-package, folder on disk, etc. 15 | 1) Portable vs. stand-alone apps 16 | 2) Publish portable app on Windows, copy to macOS and run there 17 | vi. Project options 18 | 1) Target Framework 19 | 2) netcoreapp1.1 TFM 20 | 3) Compile Include (wildcard includes) 21 | vii. Running on .NET Framework vs. .NET Core 22 | b. [demo] Installation overview 23 | c. [demo] "dotnet new" console app 24 | d. [demo] Make it a web app 25 | -------------------------------------------------------------------------------- /notes/2. MVC Applications with ASP.NET Core.md: -------------------------------------------------------------------------------- 1 | a. [slides] What's same, what's changed 2 | b. [demo] Scaffold an application 3 | i. https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/adding-model 4 | ii. (remember migrations) 5 | c. Routing and MVC are both middleware 6 | d. [demo] Show routing sample 7 | i. https://docs.microsoft.com/en-us/aspnet/core/fundamentals/routing#using-routing-middleware 8 | -------------------------------------------------------------------------------- /notes/3. Introduction to ASP.NET Core.md: -------------------------------------------------------------------------------- 1 | a. File / New / Web App overview 2 | i. [demo] (show existing app using Web Application & scaffolded controller) 3 | ii. Nothing has changed 4 | iii. Everything has changed 5 | b. Hosting 6 | i. Kestrel integration 7 | ii. [demo] Kestrel URL config 8 | c. Middleware 9 | i. Middleware introduction 10 | ii. [demo] Static Files (start with Empty project) 11 | d. Configuration 12 | i. Configuration 13 | ii. [demo] Configuration 14 | 1) Show existing web application 15 | 2) appsettings.json 16 | 3) Startup.cs config 17 | 4) User Secrets (https://docs.asp.net/en/latest/security/app-secrets.html) 18 | a) dotnet user-secrets (add) 19 | b) Breakpoint in dev mode 20 | -------------------------------------------------------------------------------- /outline.md: -------------------------------------------------------------------------------- 1 | # Outline 2 | 3 | ## Day 1 4 | | Time | Title | | 5 | | ---- | ----- | ---- | 6 | | 9:00 AM - 9:45 AM | Session #1: Introduction to the .NET Core SDK | Damian | 7 | | 9:45 AM - 10:30 AM | Lab #1 | Get bits installed, create first app | 8 | | 10:30 PM - 10:45 AM | Breakfast Snack | | 9 | | 10:45 AM - 11:15 AM | Session #2: MVC Applications with ASP.NET Core | Jon | 10 | | 11:15 AM - 12:00 PM | Lab #2 | Routing patterns, MVC basics, etc. | 11 | | 12:00 PM - 12:30 PM | Session #3: Startup, Hosting and Middleware | David | 12 | | 12:30 PM - 1:30 PM | Lunch | | 13 | | 1:30 PM - 2:15 PM | Lab #3 | WebHost, Startup, Configuration, Environments, Middleware, & IIS | 14 | | 2:15 PM - 3:00 PM | Session #4: Dependency Injection & Testing | Damian | 15 | | 3:00 PM - 3:15 PM | Break | | 16 | | 3:15 PM - 3:45 PM | Lab #4 | Use dependency injection for application services, add a unit test project | 17 | | 3:45 PM - 4:30 PM | Session #5: Logging & Error handling | David | 18 | | 4:30 PM - 5:00 PM | Lab #5 | Using logging abstractions & providers, diagnostics pages/middleware | 19 | 20 | ## Day 2 21 | | Time | Title | | 22 | | ---- | ----- | ---- | 23 | | 9:00 AM - 9:15 AM | Introduction & Day Overview | | 24 | | 9:15 AM - 10:00 AM | Session #6: Razor & Tag Helpers | Damian | 25 | | 10:10 AM - 10:30 AM | Lab #6 | Working with Tag Helpers | 26 | | 10:30 AM - 10:45 AM | Break | | 27 | | 10:45 AM - 11:30 AM | Session #7: MVC Web API | David | 28 | | 11:30 AM - 12:30 PM | Lab #7 | MVC Web API *or* Deploy app to azure | 29 | | 12:30 PM - 1:30 PM | Lunch | | 30 | | 1:30 PM - 2:15 PM | Session #8 : Single Page Applications | Jon | 31 | | 2:15 PM - 3:00 PM | Lab #8 | Single Page Applications | 32 | | 3:00 PM - 3:15 PM | Break | | 33 | | 3:15 PM - 4:45 PM | App building: Attendee List | | 34 | | 4:45 PM - 5:00 PM | Summary & Conclusion | | 35 | --------------------------------------------------------------------------------