0
I created a new project like: ASP.NET Web Application - WEB API
I created a new controller, however, I’m not being able to differentiate the ACTIONS.
If I have more than one method of type GET, at the time I request I get the error:
"Multiple actions were found that match the request: \r\nIndex on type DGBar.Controllers.TestController\r\nTeste on type DGBar.Controllers.TestController"
The configured route is the default:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
I believe the error is in the route, where it was not configured the address with "api" but I could not make the necessary adjustments to make it work.
I am ordering "https://localhost:44398/api/Test/Test" but the TEST action is being completely ignored.
Could someone help?
Thank you. https://github.com/zecaloteiro/DGBar
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
namespace DGBar.Controllers {
public class TestController : ApiController {
[HttpGet]
public IHttpActionResult Index() {
return Json("Index");
}
[HttpGet]
public IHttpActionResult Teste() {
return Json("Teste");
}
}
}
can post the methods you have in your controller as well?
– M. Bertolazo
Opa, of course. I edited the post. Thank you very much for the strength.
– osmarditto