Avatar of mathieu_cupryk
mathieu_cupryk
Flag for Canada asked on

passing a byte data through post in asp.net

I have the following message {System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
protected void Page_Load(object sender, EventArgs e)
    {
        //string fileName = ConfigurationManager.AppSettings["TempFileLocation"].ToString() + "resellerAsyncResponse.xml";
        string strXML = @"<?xml version=""1.0"" encoding=""UTF-8""?><resellerAsyncResponse xmlns=""http://www.verizonwireless.com/oas"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://www.verizonwireless.com/oas http://localhost:3681/InputFiles/matt.xsd""><messageHeader><versionNumber>001</versionNumber><vendorId>KOREWIRELESS</vendorId><channelId>B2B</channelId><channelType>RSS</channelType><requestType>ORDER</requestType><orderType>MNTMLND</orderType><referenceNumber>KOREWIRELESS_262152</referenceNumber><returnURL>http://10.253.118.230:80/receive.aspx</returnURL><resend>0</resend></messageHeader><orderResponse><mdn>2013964615</mdn><min>2013964615</min><statusCode>S0000</statusCode><errorCode>0</errorCode><errorDescription>Success</errorDescription></orderResponse></resellerAsyncResponse>";
        string url = String.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, VirtualPathUtility.ToAbsolute("~/Receive.aspx"));
        string theFile = @"C:\Temp\resellerAsyncResponse.xml";
       
        byte[] b = System.Text.Encoding.ASCII.GetBytes(strXML);



        try
        {
            System.Net.WebClient client = new WebClient();
            client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            byte[] data = client.UploadData("http://localhost/AsyncCDMA/Receive.aspx", "POST", b);
            Response.Write(System.Text.Encoding.ASCII.GetString(data));
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }

    }
the behind page.
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>

Open in new window

ASP.NET

Avatar of undefined
Last Comment
mathieu_cupryk

8/22/2022 - Mon
aibusinesssolutions

You are posting to http://localhost/AsyncCDMA/Receive.aspx which is returning the error 500.  That is where your error is most likely.
mathieu_cupryk

ASKER
yes I know why shouldi tbe giving an error.
aibusinesssolutions

I don't know, can you post the code for Receive.aspx?  That's the page that is throwing the error.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
mathieu_cupryk

ASKER
I appreciate any help. I have been stuck for days.
If you want me to post more code. just tell me.
this is a non working version I converted to C#
==========================================
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Receive.aspx.cs" Inherits="Receive" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    </div>
    </form>
</body>
</html>
---------------------------------------------------------------------------------------------
this is the page behind.
//========================================================================================================  
// Receives XML post data (from a "rest" web service) from Verizon as the result of a posted transx
// from KORE
//
// Form Post: required a single HTML form post variable called "KorePostData" not more than 1200 bytes
//
//========================================================================================================

using System;
using System.Xml;
using System.IO;
using System.Net;
using System.Configuration;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Xml.Schema;
using System.Xml.XPath;


public partial class Receive : System.Web.UI.Page
{
    #region "Page Variables"

    private string m_VersionNumber;
    private string m_VendorID;
    private string m_ChannelID;
    private string m_ChannelType;
    private string m_RequestType;
    private string m_OrderType;
    private string m_ReferenceNumber;
    private string m_ReturnURL;
    private int m_ResendCount;
    private int m_MDN;
    private int m_MIN;
    private string m_StatusCode;
    private string m_ErrorCode;
    private string m_ErrorDescription;

    #endregion

    #region "Private Page Properties"

    //message header element
    private object VersionNumber
    {
        get { return System.Convert.ToString(m_VersionNumber); }
        set
        {
            try
            {
                m_VersionNumber = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to convert \"versionNumber\" element to a string value.");
            }
        }
    }
    private object Vendor
    {
        get { return m_VendorID; }
        set
        {
            try
            {
                m_VendorID = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to convert element \"vendorId\" to a string value.");
            }
        }
    }
    private object ChannelID
    {
        get { return m_ChannelID; }
        set
        {
            try
            {
                m_ChannelID = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to convert element \"channelId\" to a string value.");
            }
        }
    }
    private object ChannelType
    {
        get { return m_ChannelType; }
        set
        {
            try
            {
                m_ChannelType = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to convert element \"channelType\" to a string value");
            }
        }

    }
    private object RequestType
    {
        get { return m_RequestType; }
        set
        {
            try
            {
                m_RequestType = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to convert element \"requestType\" to a string value.");
            }
        }
    }
    private object OrderType
    {
        get { return m_OrderType; }
        set
        {
            try
            {
                m_OrderType = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("unable to convert element \"orderType\" to a string value.");
            }
        }
    }
    private object ReferenceNumber
    {
        get { return m_ReferenceNumber; }
        set
        {
            try
            {
                m_ReferenceNumber = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("unable to convert element \"referenceNumber\" to a string value.");
            }
        }
    }
    private object ReturnURL
    {
        get { return m_ReturnURL; }
        set
        {
            try
            {
                m_ReturnURL = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("unable to convert element \"returnURL\" to a string value.");
            }
        }
    }
    private object Resend
    {
        get { return m_ResendCount; }
        set
        {
            try
            {
                m_ResendCount = System.Convert.ToInt32(value);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to convert element \"resend\" to an integer value.");
            }
        }
    }

    //order response element
    private object MDN
    {
        get { return m_MDN; }
        set
        {
            try
            {
                m_MDN = System.Convert.ToInt32(value);
            }
            catch (Exception ex)
            {
                throw new Exception("unable to convert element \"mdn\" to an integer value");
            }
        }
    }
    private object MIN
    {
        get { return m_MIN; }
        set
        {
            try
            {
                m_MIN = System.Convert.ToInt32(value);
            }
            catch (Exception ex)
            {
                throw new Exception("unable to convert element \"min\" to an integer value");
            }
        }
    }
    private object StatusCode
    {
        get { return m_StatusCode; }
        set
        {
            try
            {
                m_StatusCode = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("unable to convert element \"statusCode\" to an string value");
            }
        }
    }
    private object ErrorCode
    {
        get { return m_ErrorCode; }
        set
        {
            try
            {
                m_ErrorCode = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("unable to convert element \"errorCode\" to an string value");
            }
        }
    }
    private object ErrorDescription
    {
        get { return m_ErrorDescription; }
        set
        {
            try
            {
                m_ErrorDescription = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("unable to convert element \"errorDescription\" to an string value");
            }
        }
    }

    #endregion

    #region "Enumerations and Response Codes"
    private enum MessageHeader
    {
        VersionNumber,
        VendorID,
        ChannelID,
        ChannelType,
        RequestType,
        OrderType,
        ReferenceNumber,
        ReturnURL,
        ResendCount
    }

    private enum OrderResponse
    {
        MDN,
        MIN,
        StatusCode,
        ErrorCode,
        ErrorDescription
    }

    private enum ResponseCodes
    {
        RequestSaved = 1000,
        RequestUpdated = 1001,
        RequestNoAction = 1002,
        InvalidRequestMethod = 1010,
        InvalidPostData = 1011,
        InvalidXMLData = 1012,
        InvalidHeaderChildren = 1100,
        InvalidOrderResponseChildren = 1101,
        FailedToConnectToDataSource = 1201,
        FailedToSaveResponse = 1202
    }

    private enum QueryResult
    {
        RecordSaved = 1,
        RecordUpdated = 2,
        NoAction = 3,
        UndefinedCase = 4
    }

    #endregion

    #region "Constants"
    private const int _MAX_POST_DATA_SIZE = 1200;
    private const int REQUIRED_NUM_CHLD_HEADER = 9;
    private const int REQUIRED_NUM_CHLD_RESPONSE = 5;
    #endregion

    #region "Objects"
    private XmlDocument objInputXML;
    #endregion

    private int RETURN_CODE = 0;
    private int QUERY_RESULT = 0;
    private string RETURN_ERROR_TEXT = "";
    private string FormData = null;
    protected void Page_Load(object sender, EventArgs e)
    {



        byte[] B = new byte[Request.InputStream.Length + 1];

        Request.InputStream.Read(B, 0, B.Length);
        FormData = System.Text.ASCIIEncoding.ASCII.GetString(B);


        //FormData = System.Web.HttpUtility.UrlDecode(FormData)

        //
        //Optional DB Save
        //
        try
        {


            //try to save the request data to the DB log.
            if (System.Convert.ToBoolean(ConfigurationManager.AppSettings["SaveRequestDataToDB"].ToString()))
            {


                string SQL = "INSERT INTO tbl_log_errors_web (ErrorNumber,ErrorSource,ErrorDescription,SQLStatement,Comment,REMOTE_ADDR,SCRIPT_NAME,PATH_INFO) VALUES (@ErrorNumber,@ErrorSource,@ErrorDescription,@SQLStatement,@Comment,@REMOTE_ADDR,@SCRIPT_NAME,@PATH_INFO) ";
                SqlConnection objConn = new SqlConnection(ConfigurationManager.ConnectionStrings["PRODConnectionString"].ConnectionString);
                objConn.Open();
                SqlCommand objCmd = new SqlCommand();
                {
                    objCmd.Connection = objConn;
                    objCmd.CommandType = System.Data.CommandType.Text;
                    objCmd.CommandText = SQL;
                    objCmd.Parameters.Add("ErrorNumber", System.Data.SqlDbType.NVarChar).Value = "999999";
                    objCmd.Parameters.Add("ErrorSource", System.Data.SqlDbType.NVarChar).Value = "RSS Page";
                    objCmd.Parameters.Add("ErrorDescription", System.Data.SqlDbType.NText).Value = "Unable to process RSS response.";
                    objCmd.Parameters.Add("SQLStatement", System.Data.SqlDbType.NText).Value = objCmd.CommandText.ToString();
                    objCmd.Parameters.Add("Comment", System.Data.SqlDbType.NText).Value = FormData.ToString();
                    objCmd.Parameters.Add("REMOTE_ADDR", System.Data.SqlDbType.NVarChar).Value = Request.ServerVariables["REMOTE_ADDR"].ToString();
                    objCmd.Parameters.Add("SCRIPT_NAME", System.Data.SqlDbType.NVarChar).Value = Request.ServerVariables["SCRIPT_NAME"].ToString();
                    objCmd.Parameters.Add("PATH_INFO", System.Data.SqlDbType.NVarChar).Value = Request.ServerVariables["PATH_INFO"].ToString();
                }
                //.ExecuteNonQuery()

                objCmd.Connection = null;
                objCmd = null;
                objConn.Close();
                objConn = null;
            }

        }

        catch (Exception ex)
        {

            throw new Exception(ex.Message);
        }



        if (Request.ServerVariables["REQUEST_METHOD"] != "POST" && Request.ServerVariables["REQUEST_METHOD"] != "Post" && Request.ServerVariables["REQUEST_METHOD"] != "post")
        {

            RETURN_CODE = (int)ResponseCodes.InvalidRequestMethod;
        }


        if (RETURN_CODE != (int)ResponseCodes.InvalidRequestMethod)
        {


            //
            //Process the post data
            //

            objInputXML = new XmlDocument();


            //load up an XML document from the post data
            try
            {
                objInputXML.LoadXml(System.Convert.ToString(FormData));


                //
                //Collect the header data
                //

                XmlNodeList objNode = default(XmlNodeList);
                objNode = objInputXML.GetElementsByTagName("messageHeader");

                if (objNode.Item(0).ChildNodes.Count != REQUIRED_NUM_CHLD_HEADER)
                {

                    RETURN_CODE = (int)ResponseCodes.InvalidHeaderChildren;
                    RETURN_ERROR_TEXT += "The number of child elements of the header was " + objNode.Item(0).ChildNodes.Count.ToString() + " a should have been " + REQUIRED_NUM_CHLD_HEADER.ToString() + "<br>";
                }

                else
                {

                    VersionNumber = objNode[0].ChildNodes[(int)MessageHeader.VersionNumber].InnerText;
                    Vendor = objNode[0].ChildNodes[(int)MessageHeader.VendorID].InnerText;
                    ChannelID = objNode[0].ChildNodes[(int)MessageHeader.ChannelID].InnerText;
                    ChannelType = objNode[0].ChildNodes[(int)MessageHeader.ChannelType].InnerText;
                    RequestType = objNode[0].ChildNodes[(int)MessageHeader.RequestType].InnerText;
                    OrderType = objNode[0].ChildNodes[(int)MessageHeader.OrderType].InnerText;
                    ReferenceNumber = objNode[0].ChildNodes[(int)MessageHeader.ReferenceNumber].InnerText;
                    ReturnURL = objNode[0].ChildNodes[(int)MessageHeader.ReturnURL].InnerText;
                }

                //We don't need to check that since we will not resend transactions
                //If objNode[0].ChildNodes[(int)MessageHeader.ResendCount].InnerText Is DBNull.Value OrElse objNode[0].ChildNodes[(int)MessageHeader.ResendCount].InnerText = " " Then
                // Resend = -1
                //Else
                // Resend = objNode[0].ChildNodes[(int)MessageHeader.ResendCount].InnerText
                //End If


                //
                //Collect the reponse
                //
                objNode = objInputXML.GetElementsByTagName("orderResponse");

                if (objNode.Item(0).ChildNodes.Count != REQUIRED_NUM_CHLD_RESPONSE)
                {

                    RETURN_CODE = (int)ResponseCodes.InvalidOrderResponseChildren;
                    RETURN_ERROR_TEXT += "The number of child elements of the response was " + objNode.Item(0).ChildNodes.Count.ToString() + " a should have been " + REQUIRED_NUM_CHLD_RESPONSE.ToString() + "<br>";
                }

                else
                {

                    MDN = objNode[0].ChildNodes[(int)OrderResponse.MDN].InnerText;
                    MIN = objNode[0].ChildNodes[(int)OrderResponse.MIN].InnerText;
                    StatusCode = objNode[0].ChildNodes[(int)OrderResponse.StatusCode].InnerText;

                    if (object.ReferenceEquals(objNode[0].ChildNodes[(int)OrderResponse.ErrorCode].InnerText, DBNull.Value) || objNode[0].ChildNodes[(int)OrderResponse.ErrorCode].InnerText == " ")
                    {
                        ErrorCode = "None";
                    }
                    else
                    {
                        ErrorCode = objNode[0].ChildNodes[(int)OrderResponse.ErrorCode].InnerText;
                    }

                    ErrorDescription = objNode[0].ChildNodes[(int)OrderResponse.ErrorDescription].InnerText;
                }


                //Done with objNode
                objNode = null;
                objInputXML = null;

                //
                //Do the database insert and check the reponse.
                //

                SqlConnection objConn = new SqlConnection(ConfigurationManager.ConnectionStrings["TESTConnectionString"].ConnectionString);
                try
                {

                    //connect
                    objConn.Open();

                    using (SqlCommand objCmd = new SqlCommand())
                    {
                        {
                            objCmd.Connection = objConn;
                            objCmd.CommandType = System.Data.CommandType.StoredProcedure;
                            objCmd.CommandText = "vzw_SubmitTransactionResponse";

                            //header
                            objCmd.Parameters.Add("@RemoteIP", System.Data.SqlDbType.NVarChar).Value = Request.ServerVariables["REMOTE_ADDR"].ToString();
                            objCmd.Parameters.Add("@VersionNumber", System.Data.SqlDbType.NVarChar).Value = VersionNumber.ToString();
                            objCmd.Parameters.Add("@VendorID", System.Data.SqlDbType.NVarChar).Value = Vendor.ToString();
                            objCmd.Parameters.Add("@ChannelID", System.Data.SqlDbType.NVarChar).Value = ChannelID.ToString();
                            objCmd.Parameters.Add("@ChannelType", System.Data.SqlDbType.NVarChar).Value = ChannelType.ToString();
                            objCmd.Parameters.Add("@RequestType", System.Data.SqlDbType.NVarChar).Value = RequestType.ToString();
                            objCmd.Parameters.Add("@OrderType", System.Data.SqlDbType.NVarChar).Value = OrderType.ToString();
                            objCmd.Parameters.Add("@ReferenceNumber", System.Data.SqlDbType.NVarChar).Value = ReferenceNumber.ToString();
                            objCmd.Parameters.Add("@ReturnURL", System.Data.SqlDbType.NVarChar).Value = ReturnURL.ToString();
                            objCmd.Parameters.Add("@Resend", System.Data.SqlDbType.Int).Value = Resend;

                            //results/response
                            objCmd.Parameters.Add("@MDN", System.Data.SqlDbType.Int).Value = MDN;
                            objCmd.Parameters.Add("@MIN", System.Data.SqlDbType.Int).Value = MIN;
                            objCmd.Parameters.Add("@StatusCode", System.Data.SqlDbType.NVarChar).Value = StatusCode.ToString();
                            objCmd.Parameters.Add("@ErrorCode", System.Data.SqlDbType.NVarChar).Value = ErrorCode.ToString();
                            objCmd.Parameters.Add("@ErrorDescription", System.Data.SqlDbType.NVarChar).Value = ErrorDescription.ToString();

                            int intResult = 0;
                            try
                            {

                                //DB Execute
                                intResult = (int)objCmd.ExecuteScalar();

                                switch ((QueryResult)intResult)
                                {

                                    case QueryResult.RecordSaved:
                                        RETURN_CODE = (int)ResponseCodes.RequestSaved;
                                        break;


                                    case QueryResult.RecordUpdated:
                                        RETURN_CODE = (int)ResponseCodes.RequestUpdated;
                                        break;

                                    case QueryResult.NoAction:
                                        RETURN_CODE = (int)ResponseCodes.RequestNoAction;
                                        break;

                                    default:
                                        RETURN_CODE = (int)ResponseCodes.RequestNoAction;
                                        break;

                                }


                            }

                            catch (Exception ex)
                            {

                                RETURN_CODE = (int)ResponseCodes.FailedToSaveResponse;
                            }

                        }


                    }

                    //Command object

                    objConn.Close();
                }

                catch (Exception ex)
                {

                    RETURN_CODE = (int)ResponseCodes.FailedToConnectToDataSource;
                }


                objConn = null;
            }

            catch (Exception ex)
            {
                RETURN_CODE = (int)ResponseCodes.InvalidXMLData;
                RETURN_ERROR_TEXT += ex.Message + "<br>";
            }
        }

        Response.Clear();
        Response.ContentType = "text/html";
        //send HTML to the browser
        Response.Write(RETURN_CODE.ToString() + "<br>" + RETURN_ERROR_TEXT);



    }


}


this is received.aspx in vb.net and this one is working.
<%@ Page Language="VB" ValidateRequest="false" AutoEventWireup="false"   CodeFile="Receive.aspx.vb" Inherits="Receive" %>
===================================================================
 
'========================================================================================================
'Class: Receive.vb
'       Receives XML post data (from a "rest" web service) from Verizon as the result of a posted transx
'       from KORE
'
'Form Post: required a single HTML form post variable called "KorePostData" not more than 1200 bytes
'
'========================================================================================================
 
 
Imports System.Xml
Imports System.IO
Imports System.Net.WebClient
Imports System.Data.SqlClient
Imports System.Xml.Schema
Imports System.Xml.XPath
 
 
Partial Class Receive
    Inherits System.Web.UI.Page
 
 
#Region "Page Variables"
 
    Private m_VersionNumber As String
    Private m_VendorID As String
    Private m_ChannelID As String
    Private m_ChannelType As String
    Private m_RequestType As String
    Private m_OrderType As String
    Private m_ReferenceNumber As String
    Private m_ReturnURL As String
    Private m_ResendCount As Integer
    Private m_MDN As Integer
    Private m_MIN As Integer
    Private m_StatusCode As String
    Private m_ErrorCode As String
    Private m_ErrorDescription As String
 
#End Region
 
#Region "Private Page Properties"
 
    'message header element
    Private Property VersionNumber()
        Get
            Return System.Convert.ToString(m_VersionNumber)
        End Get
        Set(ByVal value)
            Try
                m_VersionNumber = System.Convert.ToString(value)
            Catch ex As Exception
                Throw New Exception("Unable to convert ""versionNumber"" element to a string value.")
            End Try
        End Set
    End Property
    Private Property Vendor()
        Get
            Return m_VendorID
        End Get
        Set(ByVal value)
            Try
                m_VendorID = System.Convert.ToString(value)
            Catch ex As Exception
                Throw New Exception("Unable to convert element ""vendorId"" to a string value.")
            End Try
        End Set
    End Property
    Private Property ChannelID()
        Get
            Return m_ChannelID
        End Get
        Set(ByVal value)
            Try
                m_ChannelID = System.Convert.ToString(value)
            Catch ex As Exception
                Throw New Exception("Unable to convert element ""channelId"" to a string value.")
            End Try
        End Set
    End Property
    Private Property ChannelType()
        Get
            Return m_ChannelType
        End Get
        Set(ByVal value)
            Try
                m_ChannelType = System.Convert.ToString(value)
            Catch ex As Exception
                Throw New Exception("Unable to convert element ""channelType"" to a string value")
            End Try
 
        End Set
    End Property
    Private Property RequestType()
        Get
            Return m_RequestType
        End Get
        Set(ByVal value)
            Try
                m_RequestType = System.Convert.ToString(value)
            Catch ex As Exception
                Throw New Exception("Unable to convert element ""requestType"" to a string value.")
            End Try
        End Set
    End Property
    Private Property OrderType()
        Get
            Return m_OrderType
        End Get
        Set(ByVal value)
            Try
                m_OrderType = System.Convert.ToString(value)
            Catch ex As Exception
                Throw New Exception("unable to convert element ""orderType"" to a string value.")
            End Try
        End Set
    End Property
    Private Property ReferenceNumber()
        Get
            Return m_ReferenceNumber
        End Get
        Set(ByVal value)
            Try
                m_ReferenceNumber = System.Convert.ToString(value)
            Catch ex As Exception
                Throw New Exception("unable to convert element ""referenceNumber"" to a string value.")
            End Try
        End Set
    End Property
    Private Property ReturnURL()
        Get
            Return m_ReturnURL
        End Get
        Set(ByVal value)
            Try
                m_ReturnURL = System.Convert.ToString(value)
            Catch ex As Exception
                Throw New Exception("unable to convert element ""returnURL"" to a string value.")
            End Try
        End Set
    End Property
    Private Property Resend()
        Get
            Return m_ResendCount
        End Get
        Set(ByVal value)
            Try
                m_ResendCount = System.Convert.ToInt32(value)
            Catch ex As Exception
                Throw New Exception("Unable to convert element ""resend"" to an integer value.")
            End Try
        End Set
    End Property
 
    'order response element
    Private Property MDN()
        Get
            Return m_MDN
        End Get
        Set(ByVal value)
            Try
                m_MDN = System.Convert.ToInt32(value)
            Catch ex As Exception
                Throw New Exception("unable to convert element ""mdn"" to an integer value")
            End Try
        End Set
    End Property
    Private Property MIN()
        Get
            Return m_MIN
        End Get
        Set(ByVal value)
            Try
                m_MIN = System.Convert.ToInt32(value)
            Catch ex As Exception
                Throw New Exception("unable to convert element ""min"" to an integer value")
            End Try
        End Set
    End Property
    Private Property StatusCode()
        Get
            Return m_StatusCode
        End Get
        Set(ByVal value)
            Try
                m_StatusCode = System.Convert.ToString(value)
            Catch ex As Exception
                Throw New Exception("unable to convert element ""statusCode"" to an string value")
            End Try
        End Set
    End Property
    Private Property ErrorCode()
        Get
            Return m_ErrorCode
        End Get
        Set(ByVal value)
            Try
                m_ErrorCode = System.Convert.ToString(value)
            Catch ex As Exception
                Throw New Exception("unable to convert element ""errorCode"" to an string value")
            End Try
        End Set
    End Property
    Private Property ErrorDescription()
        Get
            Return m_ErrorDescription
        End Get
        Set(ByVal value)
            Try
                m_ErrorDescription = System.Convert.ToString(value)
            Catch ex As Exception
                Throw New Exception("unable to convert element ""errorDescription"" to an string value")
            End Try
        End Set
    End Property
 
#End Region
 
#Region "Enumerations and Response Codes"
    Private Enum MessageHeader
        VersionNumber
        VendorID
        ChannelID
        ChannelType
        RequestType
        OrderType
        ReferenceNumber
        ReturnURL
        ResendCount
    End Enum
 
    Private Enum OrderResponse
        MDN
        MIN
        StatusCode
        ErrorCode
        ErrorDescription
    End Enum
 
    Private Enum ResponseCodes
        RequestSaved = 1000
        RequestUpdated = 1001
        RequestNoAction = 1002
        InvalidRequestMethod = 1010
        InvalidPostData = 1011
        InvalidXMLData = 1012
        InvalidHeaderChildren = 1100
        InvalidOrderResponseChildren = 1101
        FailedToConnectToDataSource = 1201
        FailedToSaveResponse = 1202
    End Enum
 
    Private Enum QueryResult
        RecordSaved = 1
        RecordUpdated = 2
        NoAction = 3
        UndefinedCase = 4
    End Enum
 
#End Region
 
#Region "Constants"
    Private Const _MAX_POST_DATA_SIZE As Integer = 1200
    Private Const REQUIRED_NUM_CHLD_HEADER As Integer = 9
    Private Const REQUIRED_NUM_CHLD_RESPONSE As Integer = 5
#End Region
 
#Region "Objects"
    Private objInputXML As XmlDocument
#End Region
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
        Dim RETURN_CODE As Integer = 0
        Dim QUERY_RESULT As Integer = 0
        Dim RETURN_ERROR_TEXT As String = ""
 
        Dim FormData As String = Nothing
 
        Dim B(Request.InputStream.Length) As Byte
 
        Request.InputStream.Read(B, 0, B.Length)
        FormData = System.Text.ASCIIEncoding.ASCII.GetString(B)
 
 
        'FormData = System.Web.HttpUtility.UrlDecode(FormData)
 
        '
        'Optional DB Save
        '
        Try
 
 
            'try to save the request data to the DB log.
            If System.Convert.ToBoolean(ConfigurationManager.AppSettings("SaveRequestDataToDB")) Then
 
 
                Dim SQL As String = "INSERT INTO tbl_log_errors_web (ErrorNumber,ErrorSource,ErrorDescription,SQLStatement,Comment,REMOTE_ADDR,SCRIPT_NAME,PATH_INFO) VALUES (@ErrorNumber,@ErrorSource,@ErrorDescription,@SQLStatement,@Comment,@REMOTE_ADDR,@SCRIPT_NAME,@PATH_INFO) "
                Dim objConn As New SqlConnection(ConfigurationManager.ConnectionStrings("PRODConnectionString").ConnectionString)
                objConn.Open()
                Dim objCmd As New SqlCommand
                With objCmd
                    .Connection = objConn
                    .CommandType = Data.CommandType.Text
                    .CommandText = SQL
                    .Parameters.Add("ErrorNumber", Data.SqlDbType.NVarChar).Value = "999999"
                    .Parameters.Add("ErrorSource", Data.SqlDbType.NVarChar).Value = "RSS Page"
                    .Parameters.Add("ErrorDescription", Data.SqlDbType.NText).Value = "Unable to process RSS response."
                    .Parameters.Add("SQLStatement", Data.SqlDbType.NText).Value = objCmd.CommandText.ToString
                    .Parameters.Add("Comment", Data.SqlDbType.NText).Value = FormData.ToString
                    .Parameters.Add("REMOTE_ADDR", Data.SqlDbType.NVarChar).Value = Request.ServerVariables("REMOTE_ADDR").ToString
                    .Parameters.Add("SCRIPT_NAME", Data.SqlDbType.NVarChar).Value = Request.ServerVariables("SCRIPT_NAME").ToString
                    .Parameters.Add("PATH_INFO", Data.SqlDbType.NVarChar).Value = Request.ServerVariables("PATH_INFO").ToString
                    '.ExecuteNonQuery()
                End With
 
                objCmd.Connection = Nothing
                objCmd = Nothing
                objConn.Close()
                objConn = Nothing
 
            End If
 
        Catch ex As Exception
 
            Throw New Exception(ex.Message)
 
        End Try
 
 
        If Request.ServerVariables("REQUEST_METHOD") <> "POST" AndAlso _
        Request.ServerVariables("REQUEST_METHOD") <> "Post" AndAlso _
        Request.ServerVariables("REQUEST_METHOD") <> "post" Then
 
            RETURN_CODE = ResponseCodes.InvalidRequestMethod
 
        End If
 
        If RETURN_CODE <> ResponseCodes.InvalidRequestMethod Then
 
 
            '
            'Process the post data
            '
 
            objInputXML = New XmlDocument
 
 
            'load up an XML document from the post data
            Try
                objInputXML.LoadXml(System.Convert.ToString(FormData))
 
 
                '
                'Collect the header data
                '
 
                Dim objNode As XmlNodeList
                objNode = objInputXML.GetElementsByTagName("messageHeader")
 
                If objNode.Item(0).ChildNodes.Count <> REQUIRED_NUM_CHLD_HEADER Then
 
                    RETURN_CODE = ResponseCodes.InvalidHeaderChildren
                    RETURN_ERROR_TEXT &= "The number of child elements of the header was " & objNode.Item(0).ChildNodes.Count.ToString & " a should have been " & REQUIRED_NUM_CHLD_HEADER.ToString & "<br>"
 
                Else
 
                    VersionNumber = objNode(0).ChildNodes(MessageHeader.VersionNumber).InnerText
                    Vendor = objNode(0).ChildNodes(MessageHeader.VendorID).InnerText
                    ChannelID = objNode(0).ChildNodes(MessageHeader.ChannelID).InnerText
                    ChannelType = objNode(0).ChildNodes(MessageHeader.ChannelType).InnerText
                    RequestType = objNode(0).ChildNodes(MessageHeader.RequestType).InnerText
                    OrderType = objNode(0).ChildNodes(MessageHeader.OrderType).InnerText
                    ReferenceNumber = objNode(0).ChildNodes(MessageHeader.ReferenceNumber).InnerText
                    ReturnURL = objNode(0).ChildNodes(MessageHeader.ReturnURL).InnerText
 
                    'We don't need to check that since we will not resend transactions
                    'If objNode(0).ChildNodes(MessageHeader.ResendCount).InnerText Is DBNull.Value OrElse objNode(0).ChildNodes(MessageHeader.ResendCount).InnerText = " " Then
                    '    Resend = -1
                    'Else
                    '    Resend = objNode(0).ChildNodes(MessageHeader.ResendCount).InnerText
                    'End If
 
                End If
 
                '
                'Collect the reponse
                '
                objNode = objInputXML.GetElementsByTagName("orderResponse")
 
                If objNode.Item(0).ChildNodes.Count <> REQUIRED_NUM_CHLD_RESPONSE Then
 
                    RETURN_CODE = ResponseCodes.InvalidOrderResponseChildren
                    RETURN_ERROR_TEXT &= "The number of child elements of the response was " & objNode.Item(0).ChildNodes.Count.ToString & " a should have been " & REQUIRED_NUM_CHLD_RESPONSE.ToString & "<br>"
 
                Else
 
                    MDN = objNode(0).ChildNodes(OrderResponse.MDN).InnerText
                    MIN = objNode(0).ChildNodes(OrderResponse.MIN).InnerText
                    StatusCode = objNode(0).ChildNodes(OrderResponse.StatusCode).InnerText
 
                    If objNode(0).ChildNodes(OrderResponse.ErrorCode).InnerText Is DBNull.Value OrElse objNode(0).ChildNodes(OrderResponse.ErrorCode).InnerText = " " Then
                        ErrorCode = "None"
                    Else
                        ErrorCode = objNode(0).ChildNodes(OrderResponse.ErrorCode).InnerText
                    End If
 
                    ErrorDescription = objNode(0).ChildNodes(OrderResponse.ErrorDescription).InnerText
 
                End If
 
                'Done with objNode
                objNode = Nothing
                objInputXML = Nothing
 
                '
                'Do the database insert and check the reponse.
                '
 
                Dim objConn As New SqlConnection(ConfigurationManager.ConnectionStrings("TESTConnectionString").ConnectionString)
                Try
 
                    'connect
                    objConn.Open()
 
                    Using objCmd As New SqlCommand
                        With objCmd
                            .Connection = objConn
                            .CommandType = Data.CommandType.StoredProcedure
                            .CommandText = "vzw_SubmitTransactionResponse"
 
                            'header 
                            .Parameters.Add("@RemoteIP", Data.SqlDbType.NVarChar).Value = Request.ServerVariables("REMOTE_ADDR").ToString
                            .Parameters.Add("@VersionNumber", Data.SqlDbType.NVarChar).Value = VersionNumber.ToString
                            .Parameters.Add("@VendorID", Data.SqlDbType.NVarChar).Value = Vendor.ToString
                            .Parameters.Add("@ChannelID", Data.SqlDbType.NVarChar).Value = ChannelID.ToString
                            .Parameters.Add("@ChannelType", Data.SqlDbType.NVarChar).Value = ChannelType.ToString
                            .Parameters.Add("@RequestType", Data.SqlDbType.NVarChar).Value = RequestType.ToString
                            .Parameters.Add("@OrderType", Data.SqlDbType.NVarChar).Value = OrderType.ToString
                            .Parameters.Add("@ReferenceNumber", Data.SqlDbType.NVarChar).Value = ReferenceNumber.ToString
                            .Parameters.Add("@ReturnURL", Data.SqlDbType.NVarChar).Value = ReturnURL.ToString
                            .Parameters.Add("@Resend", Data.SqlDbType.Int).Value = Resend
 
                            'results/response
                            .Parameters.Add("@MDN", Data.SqlDbType.Int).Value = MDN
                            .Parameters.Add("@MIN", Data.SqlDbType.Int).Value = MIN
                            .Parameters.Add("@StatusCode", Data.SqlDbType.NVarChar).Value = StatusCode.ToString
                            .Parameters.Add("@ErrorCode", Data.SqlDbType.NVarChar).Value = ErrorCode.ToString
                            .Parameters.Add("@ErrorDescription", Data.SqlDbType.NVarChar).Value = ErrorDescription.ToString
 
                            Dim intResult As Integer
                            Try
 
                                'DB Execute
                                intResult = .ExecuteScalar()
 
                                Select Case intResult
 
                                    Case QueryResult.RecordSaved
                                        RETURN_CODE = ResponseCodes.RequestSaved
 
 
                                    Case QueryResult.RecordUpdated
                                        RETURN_CODE = ResponseCodes.RequestUpdated
 
                                    Case QueryResult.NoAction
                                        RETURN_CODE = ResponseCodes.RequestNoAction
 
                                    Case Else
                                        RETURN_CODE = ResponseCodes.RequestNoAction
 
                                End Select
 
                            Catch ex As Exception
 
                                RETURN_CODE = ResponseCodes.FailedToSaveResponse
 
                            End Try
 
 
                        End With
 
                    End Using 'Command object
 
                    objConn.Close()
 
                Catch ex As Exception
 
                    RETURN_CODE = ResponseCodes.FailedToConnectToDataSource
 
                End Try
 
                objConn = Nothing
 
            Catch ex As Exception
                RETURN_CODE = ResponseCodes.InvalidXMLData
                RETURN_ERROR_TEXT &= ex.Message & "<br>"
            End Try
 
 
        End If
 
 
        Response.Clear()
        Response.ContentType = "text/html"   'send HTML to the browser
        Response.Write(RETURN_CODE.ToString & "<br>" & RETURN_ERROR_TEXT)
 
    End Sub
 
End Class

Open in new window

aibusinesssolutions

Ok, so the Receive.aspx that is giving you the error, is that the one that you converted to C#?
mathieu_cupryk

ASKER
yep.
âš¡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
aibusinesssolutions

Run the C# version of Receive.aspx through the debugger, and then try and post to it.  It should tell you exactly what the error is.
mathieu_cupryk

ASKER
System.Net.WebException: The remote server returned an error: (500) Internal Server Error. at System.Net.WebClient.UploadDataInternal(Uri address, String method, Byte[] data, WebRequest& request) at System.Net.WebClient.UploadData(Uri address, String method, Byte[] data) at System.Net.WebClient.UploadData(String address, String method, Byte[] data) at _Default.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\AsyncCDMA\Default.aspx.cs:line 32
aibusinesssolutions

Modify your web request.

 byte[] data = client.UploadData("Receive.aspx", "POST", b);

That should cause it to call the Receive.aspx file in your debugger, not on IIS.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
aibusinesssolutions

You may need to add a ~ like so

 byte[] data = client.UploadData("~/Receive.aspx", "POST", b);
mathieu_cupryk

ASKER
System.Net.WebException: Could not find a part of the path 'C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\~\Receive.aspx'. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\~\Receive.aspx'. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) at System.Net.FileWebStream..ctor(FileWebRequest request, String path, FileMode mode, FileAccess access, FileShare sharing) at System.Net.FileWebRequest.GetRequestStreamCallback(Object state) --- End of inner exception stack trace --- at System.Net.WebClient.UploadDataInternal(Uri address, String method, Byte[] data, WebRequest& request) at System.Net.WebClient.UploadData(Uri address, String method, Byte[] data) at System.Net.WebClient.UploadData(String address, String method, Byte[] data) at _Default.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\AsyncCDMA\Default.aspx.cs:line 33
mathieu_cupryk

ASKER
it is working but not going into the receive.aspx page.
âš¡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
aibusinesssolutions

Ok, it's trying to load the file locally, you need the full URL to your localhost:port/app.  Just do this.

byte[] data = client.UploadData(Request.Url.AbsoluteUri.Replace("Default.aspx", "") + "Receive.aspx", "POST", b);
mathieu_cupryk

ASKER
 byte[] data

is empty?
mathieu_cupryk

ASKER
now i get
System.Net.WebException: The remote server returned an error: (500) Internal Server Error. at System.Net.WebClient.UploadDataInternal(Uri address, String method, Byte[] data, WebRequest& request) at System.Net.WebClient.UploadData(Uri address, String method, Byte[] data) at System.Net.WebClient.UploadData(String address, String method, Byte[] data) at _Default.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\AsyncCDMA\Default.aspx.cs:line 34
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
aibusinesssolutions

Are you running it in debug mode?  IE did you hit F5 in Visual Studio?  It should throw the error in VS with the line highlighted where the error is.
mathieu_cupryk

ASKER
I did it in debug and no debug.
System.Net.WebException: The remote server returned an error: (500) Internal Server Error. at System.Net.WebClient.UploadDataInternal(Uri address, String method, Byte[] data, WebRequest& request) at System.Net.WebClient.UploadData(Uri address, String method, Byte[] data) at System.Net.WebClient.UploadData(String address, String method, Byte[] data) at _Default.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\AsyncCDMA\Default.aspx.cs:line 34
mathieu_cupryk

ASKER
what should i do?
âš¡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
aibusinesssolutions

Well the receive.aspx isn't working apparently, you need to fix that first.  Can you run the project with receive.aspx as the start page and see if it does anything strange?
mathieu_cupryk

ASKER
it is working fine.
could it be the autoeventwireup=true
//========================================================================================================  
// Receives XML post data (from a "rest" web service) from Verizon as the result of a posted transx
// from KORE
//
// Form Post: required a single HTML form post variable called "KorePostData" not more than 1200 bytes
//
//========================================================================================================

using System;
using System.Xml;
using System.IO;
using System.Net;
using System.Configuration;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Xml.Schema;
using System.Xml.XPath;


public partial class Receive : System.Web.UI.Page
{
    #region "Page Variables"

    private string m_VersionNumber;
    private string m_VendorID;
    private string m_ChannelID;
    private string m_ChannelType;
    private string m_RequestType;
    private string m_OrderType;
    private string m_ReferenceNumber;
    private string m_ReturnURL;
    private int m_ResendCount;
    private int m_MDN;
    private int m_MIN;
    private string m_StatusCode;
    private string m_ErrorCode;
    private string m_ErrorDescription;

    #endregion

    #region "Private Page Properties"

    //message header element
    private object VersionNumber
    {
        get { return System.Convert.ToString(m_VersionNumber); }
        set
        {
            try
            {
                m_VersionNumber = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to convert \"versionNumber\" element to a string value.");
            }
        }
    }
    private object Vendor
    {
        get { return m_VendorID; }
        set
        {
            try
            {
                m_VendorID = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to convert element \"vendorId\" to a string value.");
            }
        }
    }
    private object ChannelID
    {
        get { return m_ChannelID; }
        set
        {
            try
            {
                m_ChannelID = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to convert element \"channelId\" to a string value.");
            }
        }
    }
    private object ChannelType
    {
        get { return m_ChannelType; }
        set
        {
            try
            {
                m_ChannelType = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to convert element \"channelType\" to a string value");
            }
        }

    }
    private object RequestType
    {
        get { return m_RequestType; }
        set
        {
            try
            {
                m_RequestType = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to convert element \"requestType\" to a string value.");
            }
        }
    }
    private object OrderType
    {
        get { return m_OrderType; }
        set
        {
            try
            {
                m_OrderType = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("unable to convert element \"orderType\" to a string value.");
            }
        }
    }
    private object ReferenceNumber
    {
        get { return m_ReferenceNumber; }
        set
        {
            try
            {
                m_ReferenceNumber = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("unable to convert element \"referenceNumber\" to a string value.");
            }
        }
    }
    private object ReturnURL
    {
        get { return m_ReturnURL; }
        set
        {
            try
            {
                m_ReturnURL = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("unable to convert element \"returnURL\" to a string value.");
            }
        }
    }
    private object Resend
    {
        get { return m_ResendCount; }
        set
        {
            try
            {
                m_ResendCount = System.Convert.ToInt32(value);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to convert element \"resend\" to an integer value.");
            }
        }
    }

    //order response element
    private object MDN
    {
        get { return m_MDN; }
        set
        {
            try
            {
                m_MDN = System.Convert.ToInt32(value);
            }
            catch (Exception ex)
            {
                throw new Exception("unable to convert element \"mdn\" to an integer value");
            }
        }
    }
    private object MIN
    {
        get { return m_MIN; }
        set
        {
            try
            {
                m_MIN = System.Convert.ToInt32(value);
            }
            catch (Exception ex)
            {
                throw new Exception("unable to convert element \"min\" to an integer value");
            }
        }
    }
    private object StatusCode
    {
        get { return m_StatusCode; }
        set
        {
            try
            {
                m_StatusCode = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("unable to convert element \"statusCode\" to an string value");
            }
        }
    }
    private object ErrorCode
    {
        get { return m_ErrorCode; }
        set
        {
            try
            {
                m_ErrorCode = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("unable to convert element \"errorCode\" to an string value");
            }
        }
    }
    private object ErrorDescription
    {
        get { return m_ErrorDescription; }
        set
        {
            try
            {
                m_ErrorDescription = System.Convert.ToString(value);
            }
            catch (Exception ex)
            {
                throw new Exception("unable to convert element \"errorDescription\" to an string value");
            }
        }
    }

    #endregion

    #region "Enumerations and Response Codes"
    private enum MessageHeader
    {
        VersionNumber,
        VendorID,
        ChannelID,
        ChannelType,
        RequestType,
        OrderType,
        ReferenceNumber,
        ReturnURL,
        ResendCount
    }

    private enum OrderResponse
    {
        MDN,
        MIN,
        StatusCode,
        ErrorCode,
        ErrorDescription
    }

    private enum ResponseCodes
    {
        RequestSaved = 1000,
        RequestUpdated = 1001,
        RequestNoAction = 1002,
        InvalidRequestMethod = 1010,
        InvalidPostData = 1011,
        InvalidXMLData = 1012,
        InvalidHeaderChildren = 1100,
        InvalidOrderResponseChildren = 1101,
        FailedToConnectToDataSource = 1201,
        FailedToSaveResponse = 1202
    }

    private enum QueryResult
    {
        RecordSaved = 1,
        RecordUpdated = 2,
        NoAction = 3,
        UndefinedCase = 4
    }

    #endregion

    #region "Constants"
    private const int _MAX_POST_DATA_SIZE = 1200;
    private const int REQUIRED_NUM_CHLD_HEADER = 9;
    private const int REQUIRED_NUM_CHLD_RESPONSE = 5;
    #endregion

    #region "Objects"
    private XmlDocument objInputXML;
    #endregion

    private int RETURN_CODE = 0;
    private int QUERY_RESULT = 0;
    private string RETURN_ERROR_TEXT = "";
    private string FormData = null;
    protected void Page_Load(object sender, EventArgs e)
    {



        byte[] B = new byte[Request.InputStream.Length + 1];

        Request.InputStream.Read(B, 0, B.Length);
        FormData = System.Text.ASCIIEncoding.ASCII.GetString(B);
        Response.Write("Hello World:");


        //FormData = System.Web.HttpUtility.UrlDecode(FormData)

        //
        //Optional DB Save
        //
    //    try
    //    {


    //        //try to save the request data to the DB log.
    //        if (System.Convert.ToBoolean(ConfigurationManager.AppSettings["SaveRequestDataToDB"].ToString()))
    //        {


    //            string SQL = "INSERT INTO tbl_log_errors_web (ErrorNumber,ErrorSource,ErrorDescription,SQLStatement,Comment,REMOTE_ADDR,SCRIPT_NAME,PATH_INFO) VALUES (@ErrorNumber,@ErrorSource,@ErrorDescription,@SQLStatement,@Comment,@REMOTE_ADDR,@SCRIPT_NAME,@PATH_INFO) ";
    //            SqlConnection objConn = new SqlConnection(ConfigurationManager.ConnectionStrings["PRODConnectionString"].ConnectionString);
    //            objConn.Open();
    //            SqlCommand objCmd = new SqlCommand();
    //            {
    //                objCmd.Connection = objConn;
    //                objCmd.CommandType = System.Data.CommandType.Text;
    //                objCmd.CommandText = SQL;
    //                objCmd.Parameters.Add("ErrorNumber", System.Data.SqlDbType.NVarChar).Value = "999999";
    //                objCmd.Parameters.Add("ErrorSource", System.Data.SqlDbType.NVarChar).Value = "RSS Page";
    //                objCmd.Parameters.Add("ErrorDescription", System.Data.SqlDbType.NText).Value = "Unable to process RSS response.";
    //                objCmd.Parameters.Add("SQLStatement", System.Data.SqlDbType.NText).Value = objCmd.CommandText.ToString();
    //                objCmd.Parameters.Add("Comment", System.Data.SqlDbType.NText).Value = FormData.ToString();
    //                objCmd.Parameters.Add("REMOTE_ADDR", System.Data.SqlDbType.NVarChar).Value = Request.ServerVariables["REMOTE_ADDR"].ToString();
    //                objCmd.Parameters.Add("SCRIPT_NAME", System.Data.SqlDbType.NVarChar).Value = Request.ServerVariables["SCRIPT_NAME"].ToString();
    //                objCmd.Parameters.Add("PATH_INFO", System.Data.SqlDbType.NVarChar).Value = Request.ServerVariables["PATH_INFO"].ToString();
    //            }
    //            //.ExecuteNonQuery()

    //            objCmd.Connection = null;
    //            objCmd = null;
    //            objConn.Close();
    //            objConn = null;
    //        }

    //    }

    //    catch (Exception ex)
    //    {

    //        throw new Exception(ex.Message);
    //    }



    //    if (Request.ServerVariables["REQUEST_METHOD"] != "POST" && Request.ServerVariables["REQUEST_METHOD"] != "Post" && Request.ServerVariables["REQUEST_METHOD"] != "post")
    //    {

    //        RETURN_CODE = (int)ResponseCodes.InvalidRequestMethod;
    //    }


    //    if (RETURN_CODE != (int)ResponseCodes.InvalidRequestMethod)
    //    {


    //        //
    //        //Process the post data
    //        //

    //        objInputXML = new XmlDocument();


    //        //load up an XML document from the post data
    //        try
    //        {
    //            objInputXML.LoadXml(System.Convert.ToString(FormData));


    //            //
    //            //Collect the header data
    //            //

    //            XmlNodeList objNode = default(XmlNodeList);
    //            objNode = objInputXML.GetElementsByTagName("messageHeader");

    //            if (objNode.Item(0).ChildNodes.Count != REQUIRED_NUM_CHLD_HEADER)
    //            {

    //                RETURN_CODE = (int)ResponseCodes.InvalidHeaderChildren;
    //                RETURN_ERROR_TEXT += "The number of child elements of the header was " + objNode.Item(0).ChildNodes.Count.ToString() + " a should have been " + REQUIRED_NUM_CHLD_HEADER.ToString() + "<br>";
    //            }

    //            else
    //            {

    //                VersionNumber = objNode[0].ChildNodes[(int)MessageHeader.VersionNumber].InnerText;
    //                Vendor = objNode[0].ChildNodes[(int)MessageHeader.VendorID].InnerText;
    //                ChannelID = objNode[0].ChildNodes[(int)MessageHeader.ChannelID].InnerText;
    //                ChannelType = objNode[0].ChildNodes[(int)MessageHeader.ChannelType].InnerText;
    //                RequestType = objNode[0].ChildNodes[(int)MessageHeader.RequestType].InnerText;
    //                OrderType = objNode[0].ChildNodes[(int)MessageHeader.OrderType].InnerText;
    //                ReferenceNumber = objNode[0].ChildNodes[(int)MessageHeader.ReferenceNumber].InnerText;
    //                ReturnURL = objNode[0].ChildNodes[(int)MessageHeader.ReturnURL].InnerText;
    //            }

    //            //We don't need to check that since we will not resend transactions
    //            //If objNode[0].ChildNodes[(int)MessageHeader.ResendCount].InnerText Is DBNull.Value OrElse objNode[0].ChildNodes[(int)MessageHeader.ResendCount].InnerText = " " Then
    //            // Resend = -1
    //            //Else
    //            // Resend = objNode[0].ChildNodes[(int)MessageHeader.ResendCount].InnerText
    //            //End If


    //            //
    //            //Collect the reponse
    //            //
    //            objNode = objInputXML.GetElementsByTagName("orderResponse");

    //            if (objNode.Item(0).ChildNodes.Count != REQUIRED_NUM_CHLD_RESPONSE)
    //            {

    //                RETURN_CODE = (int)ResponseCodes.InvalidOrderResponseChildren;
    //                RETURN_ERROR_TEXT += "The number of child elements of the response was " + objNode.Item(0).ChildNodes.Count.ToString() + " a should have been " + REQUIRED_NUM_CHLD_RESPONSE.ToString() + "<br>";
    //            }

    //            else
    //            {

    //                MDN = objNode[0].ChildNodes[(int)OrderResponse.MDN].InnerText;
    //                MIN = objNode[0].ChildNodes[(int)OrderResponse.MIN].InnerText;
    //                StatusCode = objNode[0].ChildNodes[(int)OrderResponse.StatusCode].InnerText;

    //                if (object.ReferenceEquals(objNode[0].ChildNodes[(int)OrderResponse.ErrorCode].InnerText, DBNull.Value) || objNode[0].ChildNodes[(int)OrderResponse.ErrorCode].InnerText == " ")
    //                {
    //                    ErrorCode = "None";
    //                }
    //                else
    //                {
    //                    ErrorCode = objNode[0].ChildNodes[(int)OrderResponse.ErrorCode].InnerText;
    //                }

    //                ErrorDescription = objNode[0].ChildNodes[(int)OrderResponse.ErrorDescription].InnerText;
    //            }


    //            //Done with objNode
    //            objNode = null;
    //            objInputXML = null;

    //            //
    //            //Do the database insert and check the reponse.
    //            //

    //            SqlConnection objConn = new SqlConnection(ConfigurationManager.ConnectionStrings["TESTConnectionString"].ConnectionString);
    //            try
    //            {

    //                //connect
    //                objConn.Open();

    //                using (SqlCommand objCmd = new SqlCommand())
    //                {
    //                    {
    //                        objCmd.Connection = objConn;
    //                        objCmd.CommandType = System.Data.CommandType.StoredProcedure;
    //                        objCmd.CommandText = "vzw_SubmitTransactionResponse";

    //                        //header
    //                        objCmd.Parameters.Add("@RemoteIP", System.Data.SqlDbType.NVarChar).Value = Request.ServerVariables["REMOTE_ADDR"].ToString();
    //                        objCmd.Parameters.Add("@VersionNumber", System.Data.SqlDbType.NVarChar).Value = VersionNumber.ToString();
    //                        objCmd.Parameters.Add("@VendorID", System.Data.SqlDbType.NVarChar).Value = Vendor.ToString();
    //                        objCmd.Parameters.Add("@ChannelID", System.Data.SqlDbType.NVarChar).Value = ChannelID.ToString();
    //                        objCmd.Parameters.Add("@ChannelType", System.Data.SqlDbType.NVarChar).Value = ChannelType.ToString();
    //                        objCmd.Parameters.Add("@RequestType", System.Data.SqlDbType.NVarChar).Value = RequestType.ToString();
    //                        objCmd.Parameters.Add("@OrderType", System.Data.SqlDbType.NVarChar).Value = OrderType.ToString();
    //                        objCmd.Parameters.Add("@ReferenceNumber", System.Data.SqlDbType.NVarChar).Value = ReferenceNumber.ToString();
    //                        objCmd.Parameters.Add("@ReturnURL", System.Data.SqlDbType.NVarChar).Value = ReturnURL.ToString();
    //                        objCmd.Parameters.Add("@Resend", System.Data.SqlDbType.Int).Value = Resend;

    //                        //results/response
    //                        objCmd.Parameters.Add("@MDN", System.Data.SqlDbType.Int).Value = MDN;
    //                        objCmd.Parameters.Add("@MIN", System.Data.SqlDbType.Int).Value = MIN;
    //                        objCmd.Parameters.Add("@StatusCode", System.Data.SqlDbType.NVarChar).Value = StatusCode.ToString();
    //                        objCmd.Parameters.Add("@ErrorCode", System.Data.SqlDbType.NVarChar).Value = ErrorCode.ToString();
    //                        objCmd.Parameters.Add("@ErrorDescription", System.Data.SqlDbType.NVarChar).Value = ErrorDescription.ToString();

    //                        int intResult = 0;
    //                        try
    //                        {

    //                            //DB Execute
    //                            intResult = (int)objCmd.ExecuteScalar();

    //                            switch ((QueryResult)intResult)
    //                            {

    //                                case QueryResult.RecordSaved:
    //                                    RETURN_CODE = (int)ResponseCodes.RequestSaved;
    //                                    break;


    //                                case QueryResult.RecordUpdated:
    //                                    RETURN_CODE = (int)ResponseCodes.RequestUpdated;
    //                                    break;

    //                                case QueryResult.NoAction:
    //                                    RETURN_CODE = (int)ResponseCodes.RequestNoAction;
    //                                    break;

    //                                default:
    //                                    RETURN_CODE = (int)ResponseCodes.RequestNoAction;
    //                                    break;

    //                            }


    //                        }

    //                        catch (Exception ex)
    //                        {

    //                            RETURN_CODE = (int)ResponseCodes.FailedToSaveResponse;
    //                        }

    //                    }


    //                }

    //                //Command object

    //                objConn.Close();
    //            }

    //            catch (Exception ex)
    //            {

    //                RETURN_CODE = (int)ResponseCodes.FailedToConnectToDataSource;
    //            }


    //            objConn = null;
    //        }

    //        catch (Exception ex)
    //        {
    //            RETURN_CODE = (int)ResponseCodes.InvalidXMLData;
    //            RETURN_ERROR_TEXT += ex.Message + "<br>";
    //        }
    //    }

    //    Response.Clear();
    //    Response.ContentType = "text/html";
    //    //send HTML to the browser
    //    Response.Write(RETURN_CODE.ToString() + "<br>" + RETURN_ERROR_TEXT);



    }


}



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Receive.aspx.cs" Inherits="Receive" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
 
    </div>
    </form>
</body>
</html>

Open in new window

mathieu_cupryk

ASKER
I mean the receive page display but when I still get the above error. when I run the default.aspx
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
mathieu_cupryk

ASKER
i am still stuck.
mathieu_cupryk

ASKER
Ok I have solved it however I would like you to try my solution and tell me why it works.
As you being an expert you should figure this out.

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Configuration;
using System.Xml;
using System.Xml.Schema;
using System.Data;
using System.IO;
using System.Web.UI.HtmlControls;
using System.Text;



public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string strXML = @"<?xml version=""1.0"" encoding=""UTF-8""?><resellerAsyncResponse xmlns=""http://www.verizonwireless.com/oas"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://www.verizonwireless.com/oas http://localhost:3681/InputFiles/matt.xsd""><messageHeader><versionNumber>001</versionNumber><vendorId>KOREWIRELESS</vendorId><channelId>B2B</channelId><channelType>RSS</channelType><requestType>ORDER</requestType><orderType>MNTMLND</orderType><referenceNumber>KOREWIRELESS_262152</referenceNumber><returnURL>http://10.253.118.230:80/receive.aspx</returnURL><resend>0</resend></messageHeader><orderResponse><mdn>2013964615</mdn><min>2013964615</min><statusCode>S0000</statusCode><errorCode>0</errorCode><errorDescription>Success</errorDescription></orderResponse></resellerAsyncResponse>";
        string url = String.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, VirtualPathUtility.ToAbsolute("~/Receive.aspx"));
       
        XmlDocument document = new XmlDocument();
        document.LoadXml(strXML);
        SendXML(document, url);

    }

    private void SendXML(XmlDocument XmlDoc, string url)
    {
        Byte[] postArray;
        HttpWebRequest objRequest;
        Stream strmRequest;
        HttpWebResponse objResponse;
        StreamReader srResponse;
        string strReturnedResponse;
        try
        {
            // Create a new WebClient instance
            // "POST-STRING"
            postArray = UTF8Encoding.UTF8.GetBytes(XmlDoc.DocumentElement.OuterXml);

            // Initialize request object
            objRequest = (HttpWebRequest)WebRequest.Create(url);
            objRequest.Method = "POST";
            objRequest.Timeout = 50000; // 5 Mins


           
            // Upload Data implicitly sets HTTP POST as the request method
            // Add body to request
            objRequest.ContentLength = postArray.Length;
            strmRequest = objRequest.GetRequestStream();
            strmRequest.Write(postArray, 0, postArray.Length);
            strmRequest.Close();

            // Get Response
            objResponse = (HttpWebResponse)objRequest.GetResponse();
            srResponse = new StreamReader(objResponse.GetResponseStream(), Encoding.ASCII);

            // Decode and display the response.
            strReturnedResponse = srResponse.ReadToEnd();
            srResponse.Close();

            Response.Write(strReturnedResponse);
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }
}
aibusinesssolutions

Well you are using an HttpWebRequest now instead of a WebClient.

You are also posting to the variable "url", instead of http://localhost/AsyncCDMA/Receive.aspx

string url = String.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, VirtualPathUtility.ToAbsolute("~/Receive.aspx"));

That would get the URL that is running in your VS web server, not the localhost IIS web server.
âš¡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
aibusinesssolutions

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
mathieu_cupryk

ASKER
1) first it has nothing to do with passing the url.
2) it is the encoding.
If you look and trace the code you will see the size of the byte array less then.
This should give you the solution..
aibusinesssolutions

1. Passing the url to the localhost instead of localhost:3681 would take it outside of the debugging thread, so it would affect your ability to debug it correctly.
2. I'm here to help You figure the problem out, I do not have direct access to your files, so I can't trace/debug the app for you.

mathieu_cupryk

ASKER
this has nothing to do with the debugger. It works fine with the debugger.
Thanks for the help.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy