What you need is the best way to start seeding in your ASP.NET application, the quality of Random should be subtle using the method below.
public static int GenerateRandomValueDefault(int irRandValRange)
You have one instance of the global RNG that blocks, however this only happens when a new session state is created, after which the session uses only a local copy. You will get very good runtime performance with little load on the first page per person, since it generates one number from the global repository.
You can change this according to your needs, but it gives you a general idea, but it gives you a general idea.
As suggested by Henk Holterman, this lock-less solution is smaller, which can be faster and does not use HttpState.
private static int SeedCounter = 0; private readonly object SeedInitLock = new Object(); private static Random GetRandom() {
source share