Pass Array via Query String to HttpHandler

左心房为你撑大大i 提交于 2020-01-06 06:53:17

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/13198250/pass-array-via-query-string-to-httphandler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!