-2

I got error randomly on the site as per below error image.

enter image description here

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?

Vimal Usadadiya
  • 39
  • 1
  • 1
  • 5

1 Answers1

0

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.

Thanos Markou
  • 2,587
  • 3
  • 25
  • 32