-
-
Save xivol/72e09c6130d91a6216c0e8d90970d3e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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