这是我的EmployeeDetailsController.cs
namespace EmpApi.Controllers
{
[RoutePrefix("")]
public class EmployeeDetailsController : ApiController
{
[HttpGet]
[Route("Employees")]
public IEnumerable<Employee> Employees()
{
}
[HttpGet]
[Route("Details/{id}")]
public IEnumerable<Details> Details(int id)
{
}
[HttpGet]
[Route("TeamInfo/{id}")]
public IEnumerable<Team> TeamInfo(int id)
{
}
[HttpGet]
[Route("DetailsForTeam/{id}")]
public IEnumerable<Details> DetailsForTeam(int id)
{
;
}
[HttpPost]
[Route("PostEmp")]
public void PostEmp([FromBody] Employee cs)
{
}
[HttpPut]
[Route("PutEmp/{id}")]
public void PutEmp(int id, [FromBody]Employee cs)
{
}
[HttpDelete]
[Route("DeleteEmp/{id}")]
public void DeleteEmp(int id)
{
}
}
}
我制作了一个有各种服务的API。 假设我在调用api / Details / 12之后调用api / Employees,然后当我在浏览器中单击GoBack按钮时,不应触发api / Employees。 如何为我的API启用缓存。请告诉我步骤,因为我是WebApI的新手。 提前谢谢..
答案 0 :(得分:0)
在控制器声明之前添加此代码,如下所示:
[OutputCache(VaryByParam = "*", Duration = 0, NoStore = true)]
public class EmployeeDetailsController : ApiController
{
...
}