views:

28

answers:

1

I looked up the msdn documentation and it says that InvalidUserName is thrown when it does not find the username in the database, which is fine because the user I am creating should not exist in the database.

If I use [email protected], it works, but if I try it with [email protected], the status from Membership.CreateUser is InvalidUserName.

+2  A: 

Email addresses come in the form username@domain where domain is at least two parts separated by a period/dot.

The RFC Specification says that a . in the username part of the address (the part before @) is valid unless the . is the first or last character (of the username), so the behaviour that you are noticing is correct.

http://tools.ietf.org/html/rfc5322

Good find @David Stratton: From the wikipedia link in his comment...

Character . (dot, period, full stop) provided that it is not the first or last character, and provided also that it does not appear two or more times consecutively (e.g. [email protected]).

Daniel Dyson
so test.@test should be valid. Maybe this an asp.net Bug.
Xaisoft
No, the username part of your email address (test.) ends in a dot, which is invalid.
Daniel Dyson
No, it is NOT valid. The username part is ALL the text before the @. In your example, the . is the LAST part of the Username part, which, clearly, makes your example not a valid email address.Here's an easier read than the one provided... http://en.wikipedia.org/wiki/E-mail_address
David Stratton
@Daniel Dyson: +1. Thank you for finding the specification. I hada feeling it was not correct, but didn't have time to look for the spec.
David Stratton
Thanks for the help to you both. When you said the . character can't be at the beginning or end, I thought you meant at the end of the whole e-mail address.
Xaisoft