Home

LinqPad unable to pick up ApiController?

Hi, may I know why the code below unable to access via http://localhost:5000/api/my. But if I run the same code in VS, it is ok.

var builder = WebApplication.CreateBuilder();

// Add services to the container.

builder.Services.AddControllers();

var app = builder.Build();

// Configure the HTTP request pipeline.

//app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();


[ApiController]
[Route("api/[controller]")]
public class MyController : ControllerBase
{
    [HttpGet]
    public ActionResult<string> Get()
    {
        return "Hello World";
    }
}

Please help and advise. Thank you.

Sign In or Register to comment.