C
C#

help

[ASP.NET Controller] No route matches the supplied values

TTotechsStrypper8/17/2022
I'm trying to redirect my call to get the animal information from the create action method using this
return CreatedAtAction(nameof(GetById), new { Id = animal.Id }, _mapper.Map<AnimalDTO>(animal));
return CreatedAtAction(nameof(GetById), new { Id = animal.Id }, _mapper.Map<AnimalDTO>(animal));
And this is my GetById Action method
[HttpGet("{animalId}")]
public async Task<IActionResult> GetById(int animalId, CancellationToken cancellationToken = default)
{
var animal = await _animalRepository.FindByIdAsync(animalId, cancellationToken);
return animal != null ? Ok(_mapper.Map<AnimalDTO>(animal)) : NotFound("Unable to find the requested animal");
}
[HttpGet("{animalId}")]
public async Task<IActionResult> GetById(int animalId, CancellationToken cancellationToken = default)
{
var animal = await _animalRepository.FindByIdAsync(animalId, cancellationToken);
return animal != null ? Ok(_mapper.Map<AnimalDTO>(animal)) : NotFound("Unable to find the requested animal");
}
AAngius8/17/2022
The route param is animalId not Id
TTotechsStrypper8/17/2022
thanks It doesnt trigger the breakpoint that set in GetById method ?
AAngius8/17/2022
IIRC it doesn't actually call that action, because why would it? It just returns the 201 Created response and sets the Location header to the route from which you can fetch that resource That's why it needs the action name and the parameters, to construct that route

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
Autofac 5.x.x - 6.x.xHey guys, I want to update Autofac from 5.x.x -> 6.x.x but I came across the issue. Is there any easis it possible to enable cors in net framework?hi all, i understand that we can enable cors in asp net core project by specifying the **.AddCors** Would only learning blazor (for the frontend) be enough for a beginner backend developer?I don't fully understand blazor yet but from what i've gathered it's basically using C# instead of jOpen file in first instanceHi. Im creating WPF app, that can open files. But, when i have opened app and use "Open with \*my apCant convert HEXI'm trying to convert this color " #E5AA70" not sure why when it run through r it get this errorIs it possible to run code only when a hover event occurs in my application? [Answered]The application shouldn't get in the way of the user. The user should be able to hover over other ap[resolved] Cs equivalent of (0..10).map [Answered]In rust I'd write smoething like (0..10).map( to iterate over a range of numbers. Obviously I can doLLVMSharp guidance neededHey, I've wrote a simple parser and lexer for my toy language and rn I'm trying to use LLVMSharp to Newtonsoft.Json errorThe error: Unhandled exception. Newtonsoft.Json.JsonWriterException: Token PropertyName in state ProReplace text in VS within scope or highlighted?I'd like to replace a specific section of text in the same way `ctrl+r+r` would but couldn't find anWPF UIElement.IsHitVisible help neededHello, In WPF `IsHitTestVisible="False"` instead of only ignoring mouse clicks, it also ignores Mouregex help [Answered]So I made a regex with little help of copilot, it looks like this: ```regex ^ (?<source>[0-7],[0-7]