指数超出范围。必须是非负数且小于集合的大小。 [英] Index was out of range. Must be non negative and less than the size of the collection.
问题描述
这是我的WebMethod
This is my WebMethod
<WebMethod(Description:="Fetch Nested Albums", EnableSession:=True)> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
Public Function moveImages() As Object
Dim FileCount As Integer = _
HttpContext.Current.Request.Form(
HttpContext.Current.Request.Form.Count - 2)
End Function
当我尝试从.aspx页面调用Web服务时,我收到此错误
索引超出范围。必须是非负数且小于集合的大小。
如何访问请求对象?我无法在Web方法中访问会话对象,因此我不得不在Web方法中添加EnableSession:= True。
所以有任何设置请求对象呢?
When i try to call the web service from the .aspx page i get this error
"Index was out of range. Must be non negative and less than the size of the collection."
How can i access the request Object? I was not able to access the session object in the web method, so i had to add EnableSession:=True in the Web Method.
So is there any setting for the request Object too?
推荐答案
我看到这一行:
Hi,
I see this line:
Dim FileCount As Integer =
HttpContext.Current.Request.Form(
HttpContext.Current.Request.Form.Count - 2)
如果 HttpContext.Current.Request.Form.Count
小于2,那么你试着拿一个表格变量在-1处(或-2,-3,...)。
If HttpContext.Current.Request.Form.Count
is less than 2, then you try to take a form variable at place -1 (or -2, -3, ...).
这篇关于指数超出范围。必须是非负数且小于集合的大小。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!