2017-06-28 35 views
1

在application/x-www-form-urlencoded格式中发布一些数据到我的ashx处理程序。 httpcontext.request.params显示空值。我不知道什么是错的。这是我的代码,并且非常确定我已经在Postman休息客户端中发布了密钥和值。Httpcontext.request(“”)正在返回ashx处理程序中的空值

 <%@ 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 = "[email protected]" 
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 

回答

0

它应该工作。请确保Content-Type设置为application/x-www-form-urlencoded in 标头,并将值作为关键值对放在主体中。

Content-Type : application/x-www-form-urlencoded 

(点击图片查看实际尺寸) enter image description here

enter image description here

+0

我做同样的事情还是回到“没有什么',我在哪里可以上传AA截屏 –

+0

我可以看到你的web配置可能有可能是我的东西丢失 –

+0

它只是一个空白的ASP.NET Web Form项目,你可以创建一个新的,并测试上述代码 – Win