Skip to content

Instantly share code, notes, and snippets.

@xivol
Created April 10, 2025 07:10
Show Gist options
  • Save xivol/72e09c6130d91a6216c0e8d90970d3e9 to your computer and use it in GitHub Desktop.
Save xivol/72e09c6130d91a6216c0e8d90970d3e9 to your computer and use it in GitHub Desktop.
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
namespace WebApplication2
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Only add essential controller services
builder.Services.AddControllers();
// Add services to the container.
builder.Services.AddRazorPages();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
}
app.UseStaticFiles();
app.UseRouting();
app.MapRazorPages();
app.MapControllers();
app.Run();
}
}
[Route("subscribe")]
public class SubscribeController : ControllerBase
{
[HttpGet]
public IActionResult Subscribe(EmailRequest data)
{
return Ok();
}
}
public class EmailRequest
{
[Required]
[EmailAddress]
public string Email { get; set; }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment