Skip to content

Commit 79082b3

Browse files
hemanandrclaude
andcommitted
fix: resolve CreatedAtAction routing issue in UserManagementController
- Fixed InvalidOperationException "No route matches the supplied values" - Updated CreatedAtAction call with explicit controllerName parameter - User creation now properly returns 201 Created with location header 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent c4f00dc commit 79082b3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

ThingConnect.Pulse.Server/Controllers/UserManagementController.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public async Task<ActionResult<UserInfoDto>> CreateUserAsync([FromBody] CreateUs
187187
_logger.LogInformation("User created: {Username} (ID: {UserId}) by admin {AdminId}",
188188
user.UserName, user.Id, currentUser?.Id);
189189

190-
return CreatedAtAction(nameof(GetUserByIdAsync), new { id = user.Id }, new UserInfoDto
190+
var userDto = new UserInfoDto
191191
{
192192
Id = user.Id,
193193
Username = user.UserName,
@@ -196,7 +196,14 @@ public async Task<ActionResult<UserInfoDto>> CreateUserAsync([FromBody] CreateUs
196196
CreatedAt = user.CreatedAt,
197197
LastLoginAt = user.LastLoginAt,
198198
IsActive = user.IsActive
199-
});
199+
};
200+
201+
return CreatedAtAction(
202+
actionName: nameof(GetUserByIdAsync),
203+
controllerName: null, // Same controller
204+
routeValues: new { id = user.Id },
205+
value: userDto
206+
);
200207
}
201208
catch (Exception ex)
202209
{

0 commit comments

Comments
 (0)