views:

99

answers:

4

hi, I am using asp.net memebrlogin_control and getting exception "The parameter 'username' must not contain commas. Parameter name: username". 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.

Thanks in advance

A: 

Commas are not permitted in an email address in any case. What happens if you enter a username with no commas?

John Saunders
A: 

username without comma will work fine for me . I want to know all possible characters that should be disallowed in validating email

Please don't add something like this as an answer; post this as a comment to John's answer (via the "add comment" link) and delete this (your) answer (via the "delete" link). Thanks.
balpha
A: 

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

Joel Etherton
A: 

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.)

sverkerw