Conris.Controls.MVC/ValidationAttribute/ActionNameSelectorAttribute.cs

(完整代码) 958B

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
namespace Conris.Controls.MVC
{
    [AttributeUsage(AttributeTargets.Method)]
    public class FormActionSelectorAttribute : ActionNameSelectorAttribute
    {
        private readonly string[] _formName;

        public FormActionSelectorAttribute(params string[] formName)
        {
            if (formName == null)
                throw new ArgumentNullException("formName");

            _formName = formName;
        }

        public string[] FormName
        {
            get { return _formName; }
        }

        public override bool IsValidName(ControllerContext controllerContext, string actionName, System.Reflection.MethodInfo methodInfo)
        {
            return _formName.Contains(controllerContext.RequestContext.HttpContext.Request.Form["n.__formName"]);
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。