I have a very simple ASP.NET 6.0 Web API application, with a Home controller with one Get method returning text:
[ApiController]
[Route("[controller]")]
public class HomeController : Controller
{
// GET
[HttpGet]
public IActionResult Get()
{
return Ok(new { message = "Hello, World!" });
}
}
I've been able to get ASP.NET projects < 6.0 to work, but with .NET 6 I'm running into issues. There's no longer a Startup class; that functionality moved to the implicit Program class. So in my LambdaEntryPoint class (which inherits from APIGatewayProxyFunction) I'm using Program as the Startup:
protected override void Init(IWebHostBuilder builder)
{
builder.UseStartup<Program>();
}
I'm getting an error when manually testing from the AWS console: Amazon.Lambda.RuntimeSupport.ExceptionHandling.LambdaValidationException: Unable to load assembly. I believe that my naming is correct: MyAssembly::MyAssembly.LambdaEntryPoint::FunctionHandlerAsync
The only thing different about my Program class is that I had to add public partial class Program { } at the bottom so the unit tests would could find Program and run.
My Test event looks like this:
{
"resource": "/Home",
"path": "/Home",
"httpMethod": "GET",
"isBase64Encoded": true
}
It is a cut down version of the default Amazon API Gateway AWS Proxy