I am working on web api 2.0 and trying to achieve below url to access with every controller. I have created a base controller which I inherited to every controller. Now I have a scenario where I need Ping method with every controllers.
Could you please suggest to get this path?
Need below endpoint path with every controller
https://localhost/employee/Ping
https://localhost/student/Ping
Base controller
public class BaseController : ApiController
{
[HttpGet]
[Route("Ping")]
public IHttpActionResult Ping()
{
return this.Ok(HttpStatusCode.OK);
}
}
EmployeeController
[RoutePrefix("Employee")]
public class EmployeeController : BaseController
{
[HttpGet]
[Route("GetEmployee")]
public IHttpActionResult GetEmployee()
{
//Implementation
//..
}
}
StudentController
[RoutePrefix("Student")]
public class StudentController : BaseController
{
[HttpGet]
[Route("GetStudent")]
public IHttpActionResult GetStudent()
{
//Implementation
//..
}
}
Route["{controller}/Ping"]to add Ping Endpoint to different controllers