user1382306
user1382306

Reputation:

Pass Array via Query String to HttpHandler

I've looked all over, and I can't find a solution for this. Correction: I find solutions, but they (I can't make them) work.

I'm passing an array to an HttpHandler via the query string. I've read that you read it this way:

Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    Dim request As HttpRequest = context.Request

    For u = 0 To request.QueryString("arrayIneed").Count - 1
        selectPONumber.Add(request.QueryString("arrayIneed")(u))
    Next

Doing this, regardless of whether the query string format is arrayIneed=data1,data2... or arrayIneed=[data1,data2...], chops everything after = into single values.

Please help. Many thanks in advance!

Upvotes: 0

Views: 1824

Answers (1)

nat
nat

Reputation: 2197

request.QueryString("arrayIneed") 

will just pull a string out if you need it as an array then you will need to split it into one

 dim arr = Request.QueryString("arrayINeed").Split(",")
 For Each s In arr
    selectPoNumber.Add(s)
 Next

worth noting that if your po number array is one of integers, you will have to convert s into an int

Upvotes: 2

Related Questions