This commit is contained in:
ky_sunl
2021-03-19 03:13:31 +00:00
parent 05b6aa1674
commit a0b5e92db5
4 changed files with 24 additions and 2 deletions

View File

@@ -31,6 +31,8 @@ namespace Ewide.Core.WebApi
// 500
config.Services.Replace(typeof(IHttpActionInvoker), new HttpWebApiControllerActionInvoker(config));
#endregion
config.Filters.Add(new ValidateArgumentsFilter());
}
}
}

View File

@@ -8,7 +8,6 @@ using System.Web.Http;
namespace Ewide.Core.WebApi.Areas.Base.Controllers
{
[ValidateArgumentsFilter]
public class GateController : BaseController
{
/// <summary>
@@ -16,10 +15,15 @@ namespace Ewide.Core.WebApi.Areas.Base.Controllers
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[ValidateArgumentsFilter(AllowNull = true)]
public IHttpActionResult Login(LoginDTO dto)
{
return DisplayJSON(dto);
}
[ValidateArgumentsFilter(AllowNull = true)]
public IHttpActionResult AllowNullAPI(LoginDTO dto)
{
return DisplayJSON(dto);
}
}
}

View File

@@ -11,6 +11,7 @@ using System.Web.Http.Filters;
namespace Ewide.Core.WebApi
{
[AttributeUsage(AttributeTargets.All, AllowMultiple = false)]
public class ValidateArgumentsFilter : ActionFilterAttribute
{
public bool AllowNull { get; set; } = false;