How can I handle error -2147012889 returned from HttpWebRequest ?

  • Thread starter Thread starter Fresh_Air_Rider
  • Start date Start date
F

Fresh_Air_Rider

Hello,

I'm using C# to connect to a payment gateway via the HttpWebRequest
object, but the only sample project supplied by the payment gateway is
written in VB.Net.

Could someone kindly show me the equivalent C# syntax for handling the
-2147012889 error code shown in the VB.Net example code below ?

Obviously C# has no concept of the "Err" object.

Thanks in anticipation.

... ... ...
... ... ...

'Get response
objHttpResponse = objHttpRequest.GetResponse()
objStreamRes = New StreamReader(objHttpResponse.GetResponseStream(),
Encoding.ASCII)

strResponse = objStreamRes.ReadToEnd()
objStreamRes.Close()

If Err.Number <> 0 Then
'** An non zero Err.number indicates an error of some kind **
'** Check for the most common error... unable to reach the purchase
URL **
If Err.Number = -2147012889 Then
strPageError = "Your server was unable to register this
transaction with Sage Pay." & _
" Check that you do not have a firewall restricting the POST and
" & _
"that your server can correctly resolve the address " & SystemURL
(strConnectTo, "puchase")
Else
strPageError = "An Error has occurred whilst trying to register
this transaction.<BR>" & _
"The Error Number is: " & Err.Number & "<BR>" & _
"The Description given is: " & Err.Description
End If

Else
'** No transport level errors, so the message got the Sage Pay **
'** Analyse the response from Direct to check that everything is
okay **
'** Registration results come back in the Status and StatusDetail
fields **
... ... ...
... ... ...
 
Hi Pete,

Thank you so much for taking the time and trouble to provide such a
detailed and knowledgable response to my question. That is incredibly
kind and generous of you.

Many other people must be faced with the same problem as SagePay
(formerly Protx), the payment gateway company only provide a sample
Dot Net project written in VB.Net. There is no C# version.

Many thanks indeed for your reply and I will certainly have a got with
your suggestions.

Take care and all the best.

Regards
David
 
Hi Pete,

Thank you so much for taking the time and trouble to provide such a
detailed and knowledgable response to my question. That is incredibly
kind and generous of you.

Many other people must be faced with the same problem as SagePay
(formerly Protx), the payment gateway company only provide a sample
Dot Net project written in VB.Net. There is no C# version.

Many thanks indeed for your reply and I will certainly have a got with
your suggestions.

Take care and all the best.

Regards
David
 
Hello Pete,

Just to let you know that I have modified my code, based on the sample
code that you kindly supplied.

Thanks once again.

Regards
David
 
Hello Pete,

Just to let you know that I have modified my code, based on the sample
code that you kindly supplied.

Thanks once again.

Regards
David
 
LOL,

Just the code I am about to translate. Looking forward to a non design
related task.

.......flags this thread.....

:-)
 
LOL,

Just the code I am about to translate. Looking forward to a non design
related task.

.......flags this thread.....

:-)
 
Back
Top