I am using ASP.NET Core 8.0 with Angular v17+ frontend. I can only get my default get method from the controller but not my other one.
My controller looks like this:
[Route("api/values")]
[ApiController]
public class ValuesController : ControllerBase
{
// GET: api/<ValuesController>
[HttpGet]
public ActionResult<IEnumerable<string>> Get()
{
return Ok(new string[] { "ActionResult<IEnumerable<string>> Get()" });
}
[HttpGet]
[Route("getme")]
public ActionResult<IEnumerable<string>> GetMe()
{
return Ok(new string[] { Guid.NewGuid().ToString() + " | " + Guid.NewGuid().ToString() });
}
}
I can get the first method, but the second GET
method I get a
Http failure during parsing for http://localhost:4200/api/values/getme
Not sure what I am doing wrong. I did test it using the full path and that works for some reason.
This is my proxy.config.json
:
{
"/api/*": {
"target": "https://localhost:44351",
"secure": false,
"logLevel": "debug"
}
}
After hours of trying to solve this. This is what I did to fix it
Original proxy.config.json
{
"/api/*": {
"target": "https://localhost:44351",
"secure": false,
"verbose": true
}
}
Updated proxy.config.json
{
"/api/**": {
"target": "https://localhost:44351",
"secure": false,
"verbose": true
}
}
Difference is that extra *
Your welcome to ever else finds this useful.