websitepanel/WebsitePanel/Sources/WebsitePanel.WebDavPortal/CustomAttributes/FormValueRequiredAttribute.cs
2015-01-23 00:46:08 -08:00

21 lines
No EOL
668 B
C#

using System.Reflection;
using System.Web.Mvc;
namespace WebsitePanel.WebDavPortal.CustomAttributes
{
public class FormValueRequiredAttribute : ActionMethodSelectorAttribute
{
private readonly string _submitButtonName;
public FormValueRequiredAttribute(string submitButtonName)
{
_submitButtonName = submitButtonName;
}
public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo)
{
var value = controllerContext.HttpContext.Request.Form[_submitButtonName];
return !string.IsNullOrEmpty(value);
}
}
}