aspnet-core
ASP.NET Core Development
Build modern web applications and APIs with ASP.NET Core using minimal APIs, MVC, and production patterns.
Core Patterns
Minimal API
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<AppDbContext>();
builder.Services.AddScoped<IUserService, UserService>();
var app = builder.Build();
app.MapGet("/api/users", async (IUserService service) =>
{
var users = await service.GetAllAsync();
return Results.Ok(users);
});
app.MapPost("/api/users", async (User user, IUserService service) =>
{
var created = await service.CreateAsync(user);
return Results.Created($"/api/users/{created.Id}", created);
});
app.Run();
Controller Pattern
[ApiController]
[Route("api/[controller]")]
public class UsersController : ControllerBase
{
private readonly IUserService _userService;
public UsersController(IUserService userService)
{
_userService = userService;
}
[HttpGet]
public async Task<ActionResult<IEnumerable<User>>> GetAll()
{
var users = await _userService.GetAllAsync();
return Ok(users);
}
[HttpPost]
public async Task<ActionResult<User>> Create(CreateUserDto dto)
{
var user = await _userService.CreateAsync(dto);
return CreatedAtAction(nameof(GetById), new { id = user.Id }, user);
}
}
Middleware
public class RequestLoggingMiddleware
{
private readonly RequestDelegate _next;
private readonly ILogger<RequestLoggingMiddleware> _logger;
public RequestLoggingMiddleware(RequestDelegate next, ILogger<RequestLoggingMiddleware> logger)
{
_next = next;
_logger = logger;
}
public async Task InvokeAsync(HttpContext context)
{
_logger.LogInformation("Request: {Method} {Path}", context.Request.Method, context.Request.Path);
await _next(context);
}
}
Best Practices
- Use dependency injection
- Implement proper error handling
- Use async/await consistently
- Leverage middleware pipeline
- Implement authentication/authorization
- Use configuration providers
- Write integration tests
- Use proper logging
Resources
More from spjoshis/claude-code-plugins
excel-analysis
Master Excel for data analysis with pivot tables, formulas, Power Query, and advanced Excel techniques.
50flutter-performance
Optimize Flutter app performance with widget rebuilds, memory management, rendering optimization, and profiling techniques. Achieve smooth 60fps rendering.
10bloc-pattern
Master BLoC (Business Logic Component) pattern for Flutter with flutter_bloc. Learn events, states, testing, and advanced patterns for scalable apps.
9product-backlog-management
Master product backlog management with prioritization frameworks, refinement techniques, estimation, and continuous backlog optimization for maximum value delivery.
6laravel-development
Master Laravel 11 with Eloquent ORM, routing, middleware, queues, testing, and modern PHP development patterns.
6rxjs-patterns
Master RxJS in Angular with observables, operators, subjects, error handling, and reactive patterns for building responsive applications.
5