The parameter 'username' must not contain commas. Parameter name: username
I am using asp.net memebrlogin_control and getting exception "The parameter 'username' must not contain commas. Parameter name: user开发者_如何学运维name". I am using emailID as username in this
How can I remove this error, and I would also like to know that what is the list of characters that should be disallowed to validate email address.
Try using a regular expression to validate the username field before passing it to whatever method you're passing it. Here's an example:
http://www.codetoad.com/asp_email_reg_exp.asp
Read RFC 2822 for the complete email address syntax. If you work through the BNF, you'll see that "@,@"@foo.bar
is perfectly fine, if unusual. The rule you're asking for, though, can be found at section 3.2.4:
atext = ALPHA / DIGIT / ; Any character except controls,
"!" / "#" / ; SP, and specials.
"$" / "%" / ; Used for atoms
"&" / "'" /
"*" / "+" /
"-" / "/" /
"=" / "?" /
"^" / "_" /
"`" / "{" /
"|" / "}" /
"~"
atom = [CFWS] 1*atext [CFWS]
dot-atom = [CFWS] dot-atom-text [CFWS]
dot-atom-text = 1*atext *("." 1*atext)
and section 3.4.1:
addr-spec = local-part "@" domain
local-part = dot-atom / quoted-string / obs-local-part
domain = dot-atom / domain-literal / obs-domain
If you ignore everything but dot-atom
in the local-part
and domain
rules, you'll match the common-or-garden addresses. It's possible that your asp.net control doesn't accept all valid RFC2822 addresses, so you should really check that documentation.
You might do something similar to the "%<hexcode>" trick to convert a valid (or not) email address into a username argument that your control can accept.
(Mastering Regular Expressions from O'Reilly used to have a humongous one-page regex (mostly correct) for mail addresses, but it's gone in 3rd ed.)
精彩评论