在声明之前,不能引用局部变量'request'

时间:2016-06-02 08:34:47

标签: vb.net

<%
dim tutar = 0.0000
dim OGRENCI_ID = 0
 tutar = Request.QueryString("tutar") ' ERROR HERE ******
 OGRENCI_ID = Request.QueryString("OGRENCI_ID")

Dim cdata = New ECozum.HPM.Helper.Models.CustomData()
        cdata.Id = "1"
        cdata.Value = OGRENCI_ID
        cdata.Visible = 1
        cdata.Editable = 1 

        Dim list = New List(Of ECozum.HPM.Helper.Models.CustomData)
        list.Add(cdata)

        Dim request = New HttpPostRequestMessage() With { _
             .User = New User() With { _
                 .Verify = 1, _
                 .VerifyFailAct = 1, _
                 .Id = 2 _
            }, _
             .Order = New Order() With { _
                 .DateTime = DateTime.UtcNow.ToString("u"), _
                 .Reference = Guid.NewGuid().ToString() _
            }, _
             .Payment = New Payment() With { _
                 .CData = list, _
                 .Method = New List(Of Integer)() From { _
                    -1 _
                }, _
                 .Amount = tutar, _
                 .AmntEdit = 1, _
                 .SuccessUrl = "http://localhost:50/sonuc.aspx?s=basarili", _
                 .FailUrl = "http://localhost:50/sonuc.aspx?s=basarisiz", _
                 .ReturnUrl = "http://localhost:50/sonuc.aspx?s=return" _
            }, _
             .HashMethod = CInt(Hash.HashType.HMACSHA256) _
        }

在此页面中,我收到错误消息: “本地变量'请求'在声明为”之前无法引用 在线: tutar = Request.QueryString(“tutar”)

有人可以帮我搞清楚吗?

1 个答案:

答案 0 :(得分:2)

Dim request = New HttpPostRequestMessage()更改此行。使用任何随机名称,例如&#39; requestobject&#39;或者&#39; rnd123&#39;。由于您将其声明为变量,因此它与默认请求对象冲突。