Skip to content

Minmal .NET API - Delegate 'RequestDelegate' does not take 0 arguments #34390

@mindingdata

Description

@mindingdata

I'm trying to test out creating a minimal .NET Core API, with a very simple structure. e.g. :

using Microsoft.AspNetCore.Builder;

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/hello", () => "Hello, World!");

app.Run();

I seem to get the following error :

Delegate 'RequestDelegate' does not take 0 arguments

I checked for other issues inside this repo, and the only similar mention was when the cast was removed from the delegate here : #33393

Because previously you had to cast to a Func like so (And this does get my code compiling without errors).

app.MapGet("/", (Func<string>)(() => "Hello World!"));

If I run my code using dotnet run, the code actually runs fine and generates a response. So I'm thinking it could be more about the tooling I'm using, but I'm not sure where.

I have the latest .NET Core 6 - Preview 6 SDK :

.NET SDK (reflecting any global.json):
 Version:   6.0.100-preview.6.21355.2
 Commit:    7f8e0d76c0

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19042
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.100-preview.6.21355.2\

Host (useful for support):
  Version: 6.0.0-preview.6.21352.12
  Commit:  770d630b28

My VS Code version is :

Version: 1.58.2 (system setup)
Commit: c3f126316369cd610563c75b1b1725e0679adfb3
Date: 2021-07-14T22:10:15.214Z
Electron: 12.0.13
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Windows_NT x64 10.0.19042

My VS Code C# extension version is 1.23.13

My Visual Studio 2019 is version 16.10.3 (But not preview, which could be the issue)

So again :

  • Code will build fine with dotnet build
  • Code will run find using dotnet run OR running via Visual Studio
  • Code will display an output warning/error in both Visual Studio and VS Code that Delegate 'RequestDelegate' does not take 0 arguments

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-minimal-actionsController-like actions for endpoint routing

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions