Git Product home page Git Product logo

aspnetcoreapi-boilerplate's Introduction

AspNetCoreApi.Boilerplate

Base classes, Autofac modules and extensions methods to help configure ASP.Net Core Web API apps.

Build Status

Build Status

Dependencies

AspNetCoreApi.Boilerplate is a .Net Standard 2.1 class library that has the following dependencies.

This is not a full-dependency tree, but just the major dependencies listed as close to the top of the tree as possible.

How to use

  1. Create a new ASP.Net Core 3.1 API website using the "blank" template.

  2. Add the AspNetCoreApi.Boilerplate package reference.

  3. Add the other non-analyser package references shown in the sample applications.

    <Project Sdk="Microsoft.NET.Sdk.Web">
     <PropertyGroup>
       <TargetFramework>netcoreapp3.1</TargetFramework>
     </PropertyGroup>
     <ItemGroup>
       <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="6.0.0" />
       <PackageReference Include="AspNetCoreApi.Boilerplate" Version="0.2.1" />
       <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.2">
         <PrivateAssets>all</PrivateAssets>
         <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
       </PackageReference>
       <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.2" />
     </ItemGroup>
    </Project>
  4. Configure Program.cs

        public static class Program
        {
            public static void Main(string[] args)
            {
                var host = Host.CreateDefaultBuilder(args)
                    .ConfigureLogging(logging =>
                    {
                        logging.ClearProviders();
                        logging.AddSerilog();
                    })
                    .UseSerilog()
                    .UseServiceProviderFactory(new AutofacServiceProviderFactory())
                    .ConfigureWebHostDefaults(webHostBuilder =>
                    {
                        webHostBuilder
                            .UseContentRoot(Directory.GetCurrentDirectory())
                            .UseStartup<Startup>();
                    })
                    .Build();
    
                host.Run();
            }
        }
  5. For your Startup.cs there are abstract memebers for items that need to be explicitly specified and protected virtual memmbers for optional configuration.

  6. Add the settings to your appsettings.json.

    {
      "ApplicationSettings": {
        "Name": "My.App",
        "Environment": "Dev",
        "Version": "0.0.1"
      },
      "SeqSettings": {
        "Uri": "http://localhost:5341",
        "Key": ""
      },
      "ConnectionStrings": {
        "DefaultConnection": "Server=.;Initial Catalog=My.App.Db;Trusted_Connection=True"
       },
       "AllowedOrigins":  "http://localhost:4200"
    }
  7. Implement the rest of your application.

aspnetcoreapi-boilerplate's People

Contributors

themagnificent11 avatar

Watchers

James Cloos avatar  avatar

aspnetcoreapi-boilerplate's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.