I have an ASP.net website that has the following code:
Random r = new Random();
string mustBeUnique = DateTime.Now.Ticks + r.Next(1000);
It appears thought that since Random is based off of time, that two requests that happen simultaneously generate the same random number.
What is the best way to solve this?
If you’re simply looking for a unique identifier, I would recommend using a ‘Guid’ instead.
Its purpose is to be a globally unique identifier:
http://msdn.microsoft.com/en-us/library/system.guid.aspx