Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentOutOfRangeException randomly thrown when generating "rand" tracking parameter #3

Closed
ErlendSB opened this issue Nov 8, 2013 · 1 comment
Labels
Milestone

Comments

@ErlendSB
Copy link

ErlendSB commented Nov 8, 2013

Any idea why this is happening?

System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length
at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at System.String.Substring(Int32 startIndex, Int32 length)
at Piwik.Tracker.PiwikTracker.getRequest(Int32 idSite)
at Piwik.Tracker.PiwikTracker.getUrlTrackPageView(String documentTitle)
at Piwik.Tracker.PiwikTracker.doTrackPageView(String documentTitle)

I believe it is at Line 817:
Convert.ToString(new Random().Next()).Substring(2, 6)

@julienmoumne
Copy link
Member

It's indeed a bug: new Random().Next() does not necessary produce a 6 digits number.

tetsuo13 added a commit to tetsuo13/piwik-dotnet-tracker that referenced this issue Aug 26, 2014
@julienmoumne julienmoumne added this to the v1.5.1 milestone Apr 24, 2017
@julienmoumne julienmoumne changed the title ArgumentOutOfRangeException ArgumentOutOfRangeException is randomly thrown when generating &rand tracking parameter Apr 24, 2017
@julienmoumne julienmoumne changed the title ArgumentOutOfRangeException is randomly thrown when generating &rand tracking parameter ArgumentOutOfRangeException randomly thrown when generating &rand tracking parameter Apr 24, 2017
@julienmoumne julienmoumne changed the title ArgumentOutOfRangeException randomly thrown when generating &rand tracking parameter ArgumentOutOfRangeException randomly thrown when generating "rand" tracking parameter Apr 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants