我正在以application / x-www-form-urlencoded格式向我的ashx处理程序发布一些数据。 httpcontext.request.params显示空值。我不知道出了什么问题。这是我的代码,我很确定我已经在Postman rest客户端发布了密钥和值。
<%@ WebHandler Language="VB" Class="Repository" %>
Imports System
Imports System.Web
Imports System.IO
Public Class Repository : Implements IHttpHandler
Private Shared cp_merchant_id As String = "e7204ccb734bac3fdf937124448acb6c"
Private Shared cp_ipn_secret As String = "Prodigy1234"
Private Shared cp_debug_email As String = "dipad10@rocketmail.com"
Private Shared order_total As String = "0.0102"
Private txn_id As String, item_name As String, item_number As String, amount1 As Double, amount As Double, amount2 As Double, currency1 As String, _
currency2 As String, status As Integer, status_text As String, email As String, custom As String
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
If context.Request("ipn_mode") = "" Then
context.Response.Write("An Error Occured")
Exit Sub
End If
If context.Request("merchant") = "" Or context.Request("merchant") <> Trim(cp_merchant_id) Then
context.Response.Write("No or incorrect Merchant ID passed")
Exit Sub
End If
'validate if the malicious person doesnt know the ipnmode
'this means either button,cart,deposit, and so on
txn_id = context.Request("txn_id")
item_name = context.Request("item_name")
item_number = context.Request("item_number")
amount1 = context.Request("amount1")
amount2 = context.Request("amount2")
currency1 = context.Request("currency1")
currency2 = context.Request("currency2")
status = context.Request("status")
status_text = context.Request("status_text")
email = context.Request("email")
custom = context.Request("custom")
'check against order total
'If amount1 < order_total Then
' Response.Write("Amount cannot be lesser than 0.01015 BTC")
' Exit Sub
'End If
Dim commission As Double = 0.00015
'check status
If status >= 100 Or status = 2 Then
'means payment is complete save data and send mail saying transaction successful
ElseIf status < 0 Then
'payment error, this is usually final but payments will sometimes be reopened if there was no exchange rate conversion or with seller consent
context.Response.Write("Payment Error")
Else
'payment is pending, you can optionally add a note to the order page
context.Response.Write("Payment Pending")
End If
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class