【发布时间】:2014-03-17 19:47:57
【问题描述】:
这是个坏主意吗?似乎能够重用正则表达式会很好
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
public class SafeInputAttribute : RegularExpressionAttribute
{
/// <summary>
/// Regular expression for safeinput
/// </summary>
public SafeInputAttribute()
: base(@"[^{}<>]+$")
{
}
}
这样的?
SafeInputAttribute safeInput = new SafeInputAttribute();
safeInput.Validate(pin, "Login Pin");
它不起作用,安全输入为空。
感谢任何反馈。
【问题讨论】:
标签: c# regex asp.net-mvc asp.net-web-api