Hi there,

i have a sample aspx page, and my 2 users from different location are accessing the page at same time. On this page i did a response.write

sPrintString = sName & "_" & DateTime.Now.ToString("yyyyMMddHHmmssffffff") & "_" & objRandom.Next(1000, 999999) & "_" & objRandom.Next(1000, 999999)


Sometimes it happens that both of my users are getting the exactly same value in response.
And i think the random generated will be new every time as the objRandom var is local on that page.

Can you tell me how it is possible that same random number is generated for both users.

Thanks in advance
gbhatnagar :-)

Do not call the Random.Next twice in the same statement.

Try something link this.

Dim objRandom As Random = New Random()
        Dim n1 As Int32 = objRandom.Next(1000, 999999)
        Dim n2 As Int32 = objRandom.Next(1000, 999999)
        sPrintString = sName & "_" & DateTime.Now.ToString("yyyyMMddHHmmssffffff") & "_" & n1.ToString() & "_" & n2.ToString()

If you still getting the same error, try the static class approach specified in this link.