asp.net-core-routing

Routing is not working with self-hosted web API [duplicate]

江枫思渺然 提交于 2019-11-27 22:27:42
This question already has an answer here: WebApi giving 404 whilst debugging; works when published 1 answer This is essentially what I have, a very simple set of three files with fresh asp.net core 2.1 (actually copy-pasted from tutorials): public class Program { public static void Main(string[] args) { CreateWebHostBuilder(args).Build().Run(); } public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>(); } Then goes the simplest startup class Startup { public Startup(IConfiguration configuration) { Configuration =

Is it possible to have multiple GETs that vary only by parameters in ASP.NET Core?

情到浓时终转凉″ 提交于 2019-11-26 23:04:38
问题 I want to build truly RESTful web service so don't want to leverage RPC-style, so have currently this: [HttpGet] [ActionName(nameof(GetByParticipant))] public async Task<IActionResult> GetByParticipant([FromQuery]string participantId, [FromQuery]string participantType, [FromQuery]string programName) { } [HttpGet] [ActionName(nameof(GetByProgram))] public async Task<IActionResult> GetByProgram([FromQuery]string programName) { } And I believe that would work in ASP.NET Web API. But I'm getting

Routing is not working with self-hosted web API [duplicate]

冷暖自知 提交于 2019-11-26 20:58:11
问题 This question already has an answer here : WebApi giving 404 whilst debugging; works when published (1 answer) Closed 4 months ago . This is essentially what I have, a very simple set of three files with fresh asp.net core 2.1 (actually copy-pasted from tutorials): public class Program { public static void Main(string[] args) { CreateWebHostBuilder(args).Build().Run(); } public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup