Skip to content

Latest commit

 

History

History
147 lines (96 loc) · 4.98 KB

File metadata and controls

147 lines (96 loc) · 4.98 KB

ASP.NET Core Sample Projects

This repository contains multiple ASP.NET Core projects and examples, demonstrating middleware, routing, controllers, static files, and more. Each folder is a self-contained sample or learning module.

UseWhen

  • Demonstrates conditional middleware logic using the UseWhen extension.

WebApp

  • A simple web application for further extension and experimentation.

Environments

  • Demonstrates environment-specific configuration and usage in ASP.NET Core projects. See Environments/MyEnvironments for examples of using appsettings.json and appsettings.Development.json to manage settings for different environments (Development, Production, etc).

SocialMediaLinks

  • Contains examples for managing and displaying social media links in ASP.NET Core apps. See SocialMediaLinks/MySocialMediaLinks for sample code and configuration for handling social media URLs, icons, and environment-specific settings.

Unit Testing

  • Contains unit test examples for ASP.NET Core projects. See CRUD/MyUnitTest for sample test classes and usage of xUnit for testing business logic, controllers, and services. Run tests with:

    dotnet test CRUD/MyUnitTest/MyUnitTest.csproj

ASP.NET Core Sample Projects

This repository contains a large collection of ASP.NET Core and .NET sample projects, organized by topic and feature. Each folder demonstrates a specific concept, pattern, or feature in ASP.NET Core development.

Major Folders & Samples

  • Aspire/: .NET Aspire sample solution and projects for cloud-native development.
  • CitiesManager/: City management API and related configuration samples.
  • Configurations/: Custom configuration and options pattern examples.
  • Controllers/: Various controller samples, including banking, orders, and file handling.
  • CRUD/: Full CRUD sample with entities, services, contracts, and unit tests.
  • DIE/: Dependency Injection (DI) examples and documentation.
  • DIWeatherApp/: Weather app demonstrating DI and service contracts.
  • Environments/: Environment-specific configuration and usage.
  • MiddleWare/: Custom middleware implementations and usage.
  • Routing/: Routing and route constraint samples.
  • SocialMediaLinks/: Managing and displaying social media links in ASP.NET Core.
  • StaticFiles/: Serving static files (PDFs, images, etc.) from ASP.NET Core apps.
  • StockApp/: Stock app sample and configuration.
  • UseWhen/: Conditional middleware logic using the UseWhen extension.
  • ViewComponents/: View component samples for ASP.NET Core MVC.
  • Views/: Razor views and view samples.
  • WebApp/: Basic ASP.NET Core web application.

Getting Started

Prerequisites

Build and Run

  1. Clone the repository:
git clone https://github.com/EdmondAndy/aspnet.git
cd aspnet
  1. Build a project (example for MyMiddleware):
dotnet build MiddleWare/MyMiddleware/MyMiddleware.csproj

You can build other projects similarly by specifying their .csproj file.

  1. Run a project (example for MyWebApp):
dotnet run --project WebApp/MyWebApp/MyWebApp.csproj

Replace the project path as needed for other samples.

Folder Details

  • appsettings.json and appsettings.Development.json: Configuration files for each project.
  • Program.cs: Main entry point for each application.
  • Properties/launchSettings.json: Debug and launch settings.
  • Controllers/: Contains controller classes for handling HTTP requests.
  • wwwroot/: Static files (PDFs, images, etc.) served by the app.
  • Environments/: Contains projects and examples for environment-based configuration and settings.

Unit Testing

Unit tests are provided in CRUD/MyUnitTest and other folders. Run tests with:

dotnet test CRUD/MyUnitTest/MyUnitTest.csproj

Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License.

  1. Clone the repository:
git clone https://github.com/EdmondAndy/aspnet.git
cd aspnet
  1. Build a project:
dotnet build MiddleWare/MyMiddleware/MyMiddleware.csproj
dotnet build UseWhen/MyUseWhen/MyUseWhen.csproj
dotnet build WebApp/MyWebApp/MyWebApp.csproj
  1. Run a project:
dotnet run --project MiddleWare/MyMiddleware/MyMiddleware.csproj
dotnet run --project UseWhen/MyUseWhen/MyUseWhen.csproj
dotnet run --project WebApp/MyWebApp/MyWebApp.csproj

Folder Details

  • appsettings.json and appsettings.Development.json: Configuration files for each project.
  • Program.cs: Main entry point for each application.
  • Properties/launchSettings.json: Debug and launch settings.

Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License.