Convert Figma logo to code with AI

dotnet logoaspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.

35,171
9,927
35,171
3,448

Top Related Projects

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.

Json.NET is a popular high-performance JSON framework for .NET

Thoughtfully architected, obscenely fast, thoroughly enjoyable web services for all

12,849

Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.

Clean Architecture Solution Template: A starting point for Clean Architecture with ASP.NET Core

Quick Overview

ASP.NET Core is an open-source, cross-platform framework for building modern, cloud-based, and internet-connected applications. It is a redesign of ASP.NET 4.x with architectural changes that result in a leaner, more modular framework. ASP.NET Core is maintained by Microsoft and the .NET community on GitHub.

Pros

  • Cross-platform: Runs on Windows, macOS, and Linux
  • High performance: Faster than traditional ASP.NET and optimized for scalability
  • Modular architecture: Allows developers to include only necessary dependencies
  • Built-in dependency injection: Improves testability and decouples components

Cons

  • Learning curve: Developers familiar with ASP.NET 4.x may need time to adapt
  • Limited backward compatibility: Some legacy features are not supported
  • Frequent updates: Rapid release cycle may require more frequent maintenance
  • Smaller ecosystem: Fewer third-party libraries compared to older ASP.NET versions

Code Examples

  1. Creating a simple web API:
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();

var app = builder.Build();
app.MapControllers();

app.Run();

[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
    [HttpGet]
    public IEnumerable<string> Get()
    {
        return new[] { "Sunny", "Cloudy", "Rainy" };
    }
}
  1. Configuring middleware:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();

app.MapControllers();

app.Run();
  1. Dependency injection:
public class MyService : IMyService
{
    public string GetData() => "Hello from MyService";
}

builder.Services.AddScoped<IMyService, MyService>();

public class MyController : ControllerBase
{
    private readonly IMyService _myService;

    public MyController(IMyService myService)
    {
        _myService = myService;
    }

    [HttpGet]
    public string Get() => _myService.GetData();
}

Getting Started

  1. Install the .NET SDK from https://dotnet.microsoft.com/download
  2. Open a terminal and run:
    dotnet new webapi -n MyFirstAPI
    cd MyFirstAPI
    dotnet run
    
  3. Open a web browser and navigate to https://localhost:5001/swagger to see the API documentation
  4. Modify the WeatherForecastController.cs file to add your own API endpoints
  5. Use dotnet watch run for hot reloading during development

Competitor Comparisons

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.

Pros of aspnetcore

  • Actively maintained and developed by Microsoft and the community
  • Comprehensive framework for building web applications and APIs
  • Extensive documentation and large ecosystem of libraries and tools

Cons of aspnetcore

  • Larger codebase and potentially steeper learning curve
  • May include features not needed for smaller projects, leading to overhead

Code Comparison

aspnetcore:

public void ConfigureServices(IServiceCollection services)
{
    services.AddControllers();
    services.AddRazorPages();
    services.AddSignalR();
}

Additional Notes

The comparison between aspnetcore and aspnetcore is not applicable, as they are the same repository. The repository dotnet/aspnetcore is the official ASP.NET Core framework repository maintained by Microsoft. It contains the source code for the ASP.NET Core web framework, which is part of the larger .NET ecosystem.

ASP.NET Core is a cross-platform, high-performance framework for building modern, cloud-based, Internet-connected applications. It supports various application types, including web apps, APIs, microservices, and real-time applications.

The repository is open-source, allowing developers to contribute, report issues, and stay updated with the latest developments in the framework. It's widely used in the .NET community and benefits from regular updates and improvements from both Microsoft and community contributors.

Json.NET is a popular high-performance JSON framework for .NET

Pros of Newtonsoft.Json

  • Lightweight and focused solely on JSON serialization/deserialization
  • Extensive documentation and community support
  • Easier to integrate into existing projects

Cons of Newtonsoft.Json

  • Limited scope compared to the full-featured ASP.NET Core framework
  • May require additional libraries for web-specific functionality
  • Less frequent updates and maintenance

Code Comparison

Newtonsoft.Json serialization:

string json = JsonConvert.SerializeObject(myObject);
MyClass deserializedObject = JsonConvert.DeserializeObject<MyClass>(json);

ASP.NET Core (System.Text.Json) serialization:

string json = JsonSerializer.Serialize(myObject);
MyClass deserializedObject = JsonSerializer.Deserialize<MyClass>(json);

Summary

Newtonsoft.Json is a popular, lightweight JSON library that excels in its specific domain. It offers robust serialization capabilities and is well-documented. However, it lacks the comprehensive web development features provided by ASP.NET Core.

ASP.NET Core, on the other hand, is a full-fledged web application framework that includes its own JSON serialization library (System.Text.Json). While it offers a more extensive set of tools for web development, it may be overkill for projects that only require JSON functionality.

The choice between the two depends on the project's scope and requirements. Newtonsoft.Json is ideal for focused JSON operations, while ASP.NET Core is better suited for complete web application development.

Thoughtfully architected, obscenely fast, thoroughly enjoyable web services for all

Pros of ServiceStack

  • Simpler and more intuitive API design, reducing boilerplate code
  • Built-in support for multiple serialization formats (JSON, XML, CSV, etc.)
  • Comprehensive ecosystem with integrated authentication, caching, and ORM

Cons of ServiceStack

  • Commercial licensing for larger projects, which may increase costs
  • Smaller community compared to ASP.NET Core, potentially leading to fewer resources and third-party integrations
  • Steeper learning curve for developers already familiar with ASP.NET Core

Code Comparison

ServiceStack:

[Route("/hello/{Name}")]
public class Hello : IReturn<HelloResponse>
{
    public string Name { get; set; }
}

ASP.NET Core:

[HttpGet("hello/{name}")]
public IActionResult Hello(string name)
{
    return Ok(new { Message = $"Hello, {name}!" });
}

ServiceStack uses a message-based approach with DTOs, while ASP.NET Core uses attribute routing with action methods. ServiceStack's approach can lead to more reusable and testable code, but ASP.NET Core's method may be more familiar to developers coming from traditional MVC backgrounds.

Both frameworks offer powerful features for building web applications and APIs, with ServiceStack providing a more opinionated and integrated ecosystem, while ASP.NET Core offers greater flexibility and a larger community-driven ecosystem.

12,849

Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.

Pros of ABP

  • Provides a comprehensive application framework with pre-built modules and features
  • Offers a modular architecture for easier development and maintenance
  • Includes built-in multi-tenancy support

Cons of ABP

  • Steeper learning curve due to additional abstractions and concepts
  • Less flexibility for highly customized applications
  • Smaller community and ecosystem compared to ASP.NET Core

Code Comparison

ASP.NET Core (Startup.cs):

public void ConfigureServices(IServiceCollection services)
{
    services.AddControllers();
    services.AddDbContext<ApplicationDbContext>();
}

ABP (MyProjectNameModule.cs):

public override void ConfigureServices(ServiceConfigurationContext context)
{
    context.Services.AddAbpDbContext<MyProjectNameDbContext>();
    Configure<AbpAutoMapperOptions>(options => options.AddMaps<MyProjectNameModule>());
}

Both frameworks use dependency injection and modular architecture, but ABP provides more built-in functionality and abstractions out of the box. ASP.NET Core offers more flexibility and control over the application structure, while ABP aims to streamline development with pre-built modules and conventions.

Clean Architecture Solution Template: A starting point for Clean Architecture with ASP.NET Core

Pros of CleanArchitecture

  • Focused on clean architecture principles, promoting separation of concerns and maintainability
  • Provides a ready-to-use template for building scalable applications
  • Includes examples of domain-driven design and CQRS patterns

Cons of CleanArchitecture

  • Smaller community and less frequent updates compared to ASP.NET Core
  • Limited to specific architectural choices, which may not suit all project requirements
  • Less comprehensive documentation and resources available

Code Comparison

ASP.NET Core (Startup.cs):

public void ConfigureServices(IServiceCollection services)
{
    services.AddControllers();
    services.AddDbContext<ApplicationDbContext>(options =>
        options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
}

CleanArchitecture (Startup.cs):

public void ConfigureServices(IServiceCollection services)
{
    services.AddControllers();
    services.AddDbContext<AppDbContext>(options =>
        options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
    services.AddScoped<IRepository, EfRepository>();
    services.AddScoped<IMediator, Mediator>();
}

The CleanArchitecture example includes additional service registrations for the repository pattern and MediatR, demonstrating its focus on clean architecture principles and CQRS pattern implementation.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

ASP.NET Core

.NET Foundation MIT License Help Wanted Good First Issues Discord

ASP.NET Core is an open-source and cross-platform framework for building modern cloud-based internet-connected applications, such as web apps, IoT apps, and mobile backends. ASP.NET Core apps run on .NET, a free, cross-platform, and open-source application runtime. It was architected to provide an optimized development framework for apps that are deployed to the cloud or run on-premises. It consists of modular components with minimal overhead, so you retain flexibility while constructing your solutions. You can develop and run your ASP.NET Core apps cross-platform on Windows, Mac, and Linux. Learn more about ASP.NET Core.

Get started

Follow the Getting Started instructions.

Also check out the .NET Homepage for released versions of .NET, getting started guides, and learning resources.

See the Triage Process document for more information on how we handle incoming issues.

How to engage, contribute, and give feedback

Some of the best ways to contribute are to try things out, file issues, join in design conversations, and make pull-requests.

Reporting security issues and bugs

Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) secure@microsoft.com. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.

Related projects

These are some other repos for related projects:

Code of conduct

See CODE-OF-CONDUCT

Nightly builds

This table includes links to download the latest builds of the ASP.NET Core Shared Framework. Also included are links to download the Windows Hosting Bundle, which includes the ASP.NET Core Shared Framework, the .NET Runtime Shared Framework, and the IIS plugin (ASP.NET Core Module). You can download the latest .NET Runtime builds here, and the latest .NET SDK builds here. If you're unsure what you need, then install the SDK; it has everything except the IIS plugin.

PlatformShared Framework (Installer)Shared Framework (Binaries)Hosting Bundle (Installer)
Windows x64InstallerBinariesInstaller
Windows x86InstallerBinariesInstaller
Windows arm64InstallerBinariesInstaller
macOS x64N/ABinariesN/A
macOS arm64N/ABinariesN/A
Linux x64Deb Installer - RPM InstallerBinariesN/A
Linux armN/ABinariesN/A
Linux arm64RPM InstallerBinariesN/A
Linux-musl-x64N/ABinariesN/A
Linux-musl-armN/ABinariesN/A
Linux-musl-arm64N/ABinariesN/A