You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The TypeSpec code generator for ASP.NET Core controllers incorrectly generates absolute route templates in the base controller classes, leading to routing issues in derived controllers. This prevents the framework from correctly combining base routes defined on derived controllers with the action-specific route templates in the base class.
Description:
When generating code for ASP.NET Core controllers with inheritance, the generator incorrectly applies [Route] attributes with absolute paths (starting with /) to the action methods in the base controller class. This overrides the base route defined on the derived controller and prevents the framework from correctly matching requests to the intended endpoints.
Expected Behavior:
The generated code should:
Define a base route on the derived controller using the [Route] attribute (e.g., [Route("projects")]).
Use relative route templates in the HTTP verb attributes (e.g., [HttpGet("{projectId}")], [HttpPost("{projectId}")], [HttpDelete("{projectId}")]) on the action methods in the base controller class.
Allow the framework to correctly combine the base route from the derived controller with the relative route templates from the base controller to form the complete URL path.
Actual Behavior:
The generated code:
Defines a base route on the derived controller using the [Route] attribute (e.g., [Route("projects")]).
Incorrectly applies [Route] attributes with absolute paths (e.g., [Route("/projects/{projectId}")]) to the action methods in the base controller class.
This results in the framework ignoring the base route defined on the derived controller and failing to match requests to the intended endpoints.
The TypeSpec code generator for ASP.NET Core controllers incorrectly generates absolute route templates in the base controller classes, leading to routing issues in derived controllers. This prevents the framework from correctly combining base routes defined on derived controllers with the action-specific route templates in the base class.
Description:
When generating code for ASP.NET Core controllers with inheritance, the generator incorrectly applies
[Route]
attributes with absolute paths (starting with/
) to the action methods in the base controller class. This overrides the base route defined on the derived controller and prevents the framework from correctly matching requests to the intended endpoints.Expected Behavior:
The generated code should:
[Route]
attribute (e.g.,[Route("projects")]
).[HttpGet("{projectId}")]
,[HttpPost("{projectId}")]
,[HttpDelete("{projectId}")]
) on the action methods in the base controller class.Actual Behavior:
The generated code:
[Route]
attribute (e.g.,[Route("projects")]
).[Route]
attributes with absolute paths (e.g.,[Route("/projects/{projectId}")]
) to the action methods in the base controller class.Example:
Incorrect Generated Code (in base controller):
Correct Generated Code (in base controller):
Derived Controller:
Reproduction
Steps to Reproduce:
Checklist
The text was updated successfully, but these errors were encountered: