public class CheckCertAttribute : ActionFilterAttribute
{
///
/// 验证证书是否有效
///
public bool ValidCert { get; set; }
///
/// 解析证书
///
public bool ResolveCert { get; set; }
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
//判断一些事情
//没有通过
return;
}
}
[HttpPost]
[CheckCert(ValidCert = true)]
public void GetCityCodeByName(string cityName)
{
string cityCode = string.Empty;
var success = true;
var message = "成功";
try
{
//..
}
catch (Exception ex)
{
success = false;
message = ex.Message;
}
WritResultToPage(cityCode, message, success);
}
为什么 我拦截器 已经 return 了 还会执行 action 里面的代码?需要什么设置么?