Hi All,
I need help with a problem that presented the other day after having the code working perfectly for a while. I'm not sure if anyone modified some settings in the server but now I cannot find anything wrong nor in the code nor in the server settings.
I have a listener for PayPal IPN that at one point has to make a POST as it follows:
Public Sub MakeHttpPost()
Dim req As HttpWebRequest = DirectCast(WebRequest.Create(Me.PostUrl), HttpWebRequest)
req.Method = "POST"
req.ContentLength = Me.RequestLength.Length + 21
req.ContentType = "application/x-www-form-urlencoded"
Dim param As Byte() = HttpContext.Current.Request.BinaryRead(HttpContext.Current.Request.ContentLength)
Me.RequestLength = Encoding.ASCII.GetString(param)
Me.RequestLength += "&cmd=_notify-validate"
req.ContentLength = Me.RequestLength.Length
req.UseDefaultCredentials = True
Dim streamOut As New StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII)
streamOut.Write(Me.RequestLength)
streamOut.Close()
Dim streamIn As New StreamReader(req.GetResponse().GetResponseStream())
Me.Response = streamIn.ReadToEnd()
streamIn.Close()
End Sub
When I run this code in the development server, everything works ok but in the production server gives the following error:
Server Error in '/' Application.
The remote server returned an error: (403) Forbidden.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Net.WebException: The remote server returned an error: (403) Forbidden.
Source Error:
Line 612: streamOut.Write(Me.RequestLength)
Line 613: streamOut.Close()
Line 614: Dim streamIn As New StreamReader(req.GetResponse().GetResponseStream())
Line 615: Me.Response = streamIn.ReadToEnd()
Line 616: streamIn.Close()
Stack Trace:
[WebException: The remote server returned an error: (403) Forbidden.]
System.Net.HttpWebRequest.GetResponse() +8765848
PPIPN.MakeHttpPost() in E:\SiteCorcovadoArts\App_Code\PayPal_Function.vb:614
PP_IPN_Process.Page_Load(Object sender, EventArgs e) in E:\SiteCorcovadoArts\PP_IPN_Process.aspx.vb:29
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178
If anyone could help, I would appreciate.
Thanks in advance