我正在做一个web api来处理遗留系统。这个web api的工作方式与旧的一样。安全性是随着每个呼叫一起发送安全令牌。这意味着我需要在提供数据之前检查令牌。我有这样的方法:如何在我的Web API 2解决方案中发送“禁止”响应?
public List<User> Get(string id, string securityToken)
{
//ValidateToken(securityToken);
return userRepository.LoadAll();
}
在我的方法,我想validateToken()方法返回一个“禁止”的HttpResponse如果我不能验证。我如何去做这件事?
http://stackoverflow.com/questions/17201255/returning-http-403-in-a-webapi-method – Josh