file than Startup.cs
I want all routes with their methods and controller actions in same file
what should I do ?
Why not follow a convention, then you just have to set up the mask in Startup.cs.
with convention we can't set http method and controller action both toghether as I know 🤔
Can you not use attributes like HttpGet and HttpPost for that?
I can but I don't like that 😕 I want to seperate them like other frameworks in other languages
But asp.net has its own convention, and it’s usually best to follow that unless you have a good reason not to.
I tried to do something similar: https://github.com/ronnygunawan/express-netcore
good but didn't need that here we go... 1) app.UseEndpoints(Routes.routes); 2) public static class Routes { public static void routes(IEndpointRouteBuilder router) { router.MapGet("/", HomeController.Index); } } 3) public class HomeController : Controller { public static async Task Index(HttpContext ctx) { await ctx.Response.WriteAsync("f*** this life"); } }
I needed it for DI
Обсуждают сегодня