Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When targeting .NET 8 preview 1 and using both [Http*]
and [Route("/my/path/template")]
attributes on a controller method, an ASP0023 warning is emitted which is a new behaviour that wasn't observed in .NET 7.
If you ignore the warnings, the code will run and the endpoints can be called and return the expected responses for their respective verbs.
Expected Behavior
No warning generated if a controller method can use both [Http*]
and [Route]
attributes and can be used as expected
Steps To Reproduce
using Microsoft.AspNetCore.Mvc;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
var app = builder.Build();
app.MapControllers();
app.Run();
public class MyController : Controller
{
[HttpGet]
[Route("Person")]
public IActionResult Get() => Ok("You GET me");
[HttpPut]
[Route("Person")]
public IActionResult Put() => Ok("You PUT me");
}
Exceptions (if any)
No response
.NET Version
8.0.100-preview.1.23115.2
Anything else?
dotnet --info
.NET SDK:
Version: 8.0.100-preview.1.23115.2
Commit: 913e4679b3
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.100-preview.1.23115.2\
Host:
Version: 8.0.0-preview.1.23110.8
Architecture: x64
Commit: 7deac7d6da
.NET SDKs installed:
7.0.200 [C:\Program Files\dotnet\sdk]
8.0.100-preview.1.23115.2 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.0-preview.1.23112.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.0-preview.1.23110.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.0-preview.1.23112.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]