Each user will provide a unique ID used to identify this person. If some ID is busy, the user will be asked to choose another ID, until a new unique value is chosen.
One problem is: this ID can contain characters illegal for the name of the file system object or URL, so you will need to escape them. One of the simplest ways to do it is
UrlEncode
:
http://msdn.microsoft.com/en-us/library/zttxte6w%28v=vs.110%29.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.web.httputility.urlencode.aspx[
^].
After UTL encoding, the names will remain unique. However, if you want to use some other method of escaping, escaped names may become non-unique. You need to choose the name for the URL at the moment of user registration. If you find that the URL is already taken, make it unique, say, by appending some integer number to it. Simply start with, say, 1, and increment this value until the resulting concatenated name becomes unique (you can develop algorithm with better performance, this is just the idea).
—SA