I got error randomly on the site as per below error image.
I have used just for loop to add Route to RouteTable and I have clear Routes before alter Route collection.
RouteTable.Routes.Clear()
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
RouteTable.Routes.MapPageRoute(Convert.ToString(ds.Tables(0).Rows(i)("routename")), Convert.ToString(ds.Tables(0).Rows(i)("tm_RouteURL")), Convert.ToString(ds.Tables(0).Rows(i)("tm_PhysicalFile")), False, Nothing, Nothing, _
New RouteValueDictionary() From { _
{Convert.ToString(ds.Tables(0).Rows(i)("tm_ParameterName1")), Convert.ToString(ds.Tables(0).Rows(i)("tm_ParameterValue1"))} _
})
Next
I could not figure out why this error is occurred. Anyone knows why this is happening with Routing?
You are trying to alter (add-delete item) a collection during a foreach iteration probably and that's why you get this message.
You can use a list instead and add-remove item through there.