Quantcast
Channel: Coding4Fun Blog - Channel 9
Viewing all articles
Browse latest Browse all 453

45 (and counting) ASP.NET Core Samples

$
0
0

I came across this repo by accident and as soon as I saw it I knew I had today's post. I don't know about you, but I learn code by looking at code. Today's project is 45 and count cool ASP.NET code samples, from Hello World and up...

dodyg/practical-aspnetcore

45 samples for aspnetcore fundamentals (updated daily)

Some of the samples you see here involve mixed projects (net451) that will run only in Windows. For many .NET developers, full framework is the reality for forseeable future. We are not going to port multi-year production systems to run on Linux. We want to improve the creaky .NET MVC 2.0 that we have lying around and bring it up to speed to aspnetcore MVC.

All these projects require the following dependencies

  "Microsoft.AspNetCore.Hosting" : "1.0.0-*" 

This dependency pulls its own dependencies which you can check at project.lock.json.
This allows us to not explicitly specify some dependencies ourselves.

If a sample require additional dependencies, I will list them.

I highly recommend using Visual Studio Code to play around with these samples but it is not required.

To run these samples, simply open your command line console, go to each folder and execute dotnet restore and then continue with dotnet watch run.

  • Hello World with reload

    Setup your most basic web app and enable the change+refresh development experience.

    We are using IApplicationBuilder Run, an extension method for adding terminal middleware.

  • Hello World with startup basic

    This project contains all the available services available in Startup class constructor, ConfigureServices and Configure methods. ...

  • Routing

    We take dependency on "Microsoft.AspNetCore.Routing" : "1.0.0-*" to enable routing facilities in your aspnetcore apps. There are several samples to illuminate this powerful library. ...

  • Middleware

We will explore all aspect of middleware building in this section. There is no extra dependency taken other than Kestrel and dotnet watch. ...

  • Features

Features are collection of objects you can obtain from the framework at runtime that serve different purposes.

  • Dependency Injection

aspnetcore lives and die by DI. It relies on Microsoft.Extensions.DependencyInjection library. There is no need to put this dependency in your project.json explicitly because aspnetcore already has this package as its own dependency.

  • In Memory Caching (a.k.a local cache)

These samples depends on Microsoft.Extensions.Caching.Memory library. Please add this dependency to your project.json. ...

  • Configuration

This section is all about configuration, from memory configuration to INI, JSON and XML. ...

  • Localization and Globalization

This section is all about languages, culture, etc ...

  • Serve static files

    Simply serve static files (html, css, images, etc).

    This additional dependency is required to enable the functionality "Microsoft.AspNetCore.StaticFiles": "1.0.0".

    There are two static files being serve in this project, index.html and hello.css. They are stored under wwwroot folder, which is the default folder location for this library.

    To access them you have to refer them directly e.g. localhost:5000/index.html and localhost:5000/hello.css.

  • Markdown server

    Serve markdown file as html file. You will see how you can create useful app using a few basic facilities in aspnetcore.

    We take "CommonMark.Net" : "0.13.4" as dependency.

... [Click through to see them all]




Viewing all articles
Browse latest Browse all 453

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>