Commit f67e2177 authored by liudong1993's avatar liudong1993

增加表单重复验证

parent 0baa9691
......@@ -89,26 +89,25 @@ namespace Mall.WebApi.Filter
string controllerName = actionContext.ActionDescriptor.RouteValues["controller"].ToString().ToLower();
string actionName = actionContext.ActionDescriptor.RouteValues["action"].ToString().ToLower();
//string areaName = actionContext.ActionDescriptor.RouteValues["area"].ToString().ToLower();
if (!actionName.ToLower().Contains("get"))
{
string cachedKey = SecurityHelper.MD5(string.Format("cmd={0}&token={1}", controllerName + "/" + actionName, token));
try
{
//if (UserReidsCache.Exists(cachedKey))//判断表单是否重复提交
//{
// actionContext.Result = new Microsoft.AspNetCore.Mvc.JsonResult(new ApiResult
// {
// resultCode = (int)ResultCode.FormRepeatSubmit,
// message = "表单重复提交,请稍后再试",
// data = null
// });
//}
//else
//{
// //默认2秒钟之内不能重复提交
// UserReidsCache.Set(cachedKey, 1, 2);
//}
if (UserReidsCache.Exists(cachedKey))//判断表单是否重复提交
{
actionContext.Result = new Microsoft.AspNetCore.Mvc.JsonResult(new ApiResult
{
resultCode = (int)ResultCode.FormRepeatSubmit,
message = "表单重复提交,请稍后再试",
data = null
});
}
else
{
//默认3秒钟之内不能重复提交
UserReidsCache.Set(cachedKey, 1, 3);
}
}
catch
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment