Click here to Skip to main content
15,883,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

Can someone please check my code. I keep getting error when I process a creditcard. Everytime I click submit to process creditcard payment, it gives error

Server Error in '/' Application.
Root element is missing.
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.Xml.XmlException: Root element is missing.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[XmlException: Root element is missing.]
   System.Xml.XmlTextReaderImpl.Throw(Exception e) +72
   System.Xml.XmlTextReaderImpl.ParseDocumentContent() +5470471
   System.Xml.XmlTextReaderImpl.Read() +163
   System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) +112
   System.Xml.XmlDocument.Load(XmlReader reader) +107
   System.Xml.XmlDocument.LoadXml(String xml) +160
   FabricsPlusCom.ShoppingCartCheckout.SendtoEWAY() +1551
   FabricsPlusCom.ShoppingCartCheckout.ShowStep(Int32 TheStep) +5245
   FabricsPlusCom.ShoppingCartCheckout.btnNext_Click(Object sender, EventArgs e) +79
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9779798
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +204
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +12
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1639


What I have tried:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.web>
    <!--  DYNAMIC DEBUG COMPILATION
          Set compilation debug="true" to insert debugging symbols (.pdb information)
          into the compiled page. Because this creates a larger file that executes
          more slowly, you should set this value to true only when debugging and to
          false at all other times. For more information, refer to the documentation about
          debugging ASP.NET files.
    -->
	<compilation defaultLanguage="vb" debug="true" targetFramework="4.6" />
	<httpRuntime targetFramework="4.6" />
    <!--  CUSTOM ERROR MESSAGES
          Set customErrors mode="On" or "RemoteOnly" to enable custom error messages, "Off" to disable. 
          Add <error> tags for each of the errors you want to handle.
    -->
    <customErrors mode="Off" />
    <!--  AUTHENTICATION 
          This section sets the authentication policies of the application. Possible modes are "Windows", 
          "Forms", "Passport" and "None"
    -->
    <authentication mode="Forms">
      <forms loginUrl="/Admin/Login.aspx" />
    </authentication>
    <!--  AUTHORIZATION 
          This section sets the authorization policies of the application. You can allow or deny access
          to application resources by user or role. Wildcards: "*" mean everyone, "?" means anonymous 
          (unauthenticated) users.
    -->
    <authorization>
      <allow users="*" />
      <!-- Allow all users -->
      <!--  <allow     users="[comma separated list of users]"
                             roles="[comma separated list of roles]"/>
                  <deny      users="[comma separated list of users]"
                             roles="[comma separated list of roles]"/>
            -->
    </authorization>
    <!--  APPLICATION-LEVEL TRACE LOGGING
          Application-level tracing enables trace log output for every page within an application. 
          Set trace enabled="true" to enable application trace logging.  If pageOutput="true", the
          trace information will be displayed at the bottom of each page.  Otherwise, you can view the 
          application trace log by browsing the "trace.axd" page from your web application
          root. 
    -->
    <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />
    <!--  SESSION STATE SETTINGS
          By default ASP.NET uses cookies to identify which requests belong to a particular session. 
          If cookies are not available, a session can be tracked by adding a session identifier to the URL. 
          To disable cookies, set sessionState cookieless="true".
    -->
    <sessionState
      mode="InProc"
      cookieless="false" 
      timeout="60"
    />    
    <!--  GLOBALIZATION
          This section sets the globalization settings of the application. 
	Provider=Microsoft.Jet.OLEDB.4.0;Data Source=;Persist Security Info=False
	D:\vhosts\fabricsplus.com.au\httpdocs\ASP\FPDB\dbFabricsPlus.mdb
	Changed Text
    -->
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
   <!--  <identity impersonate="true"/> --> 
	<!--
	<machineKey validationKey="50F768F66ED5CCA46CBF28C382D95C6BCD7BC696A74B47DCC17928736541DF95A7C94EAF4147D6F7B3C2BB44286FB99B54A7F71C77854ABEEF19252265216FB9" decryptionKey="8D97CB08D9D841D496615A7DB34C01F86E3256CB54734F9FC693B648B14333B5" validation="SHA1" decryption="AES" />
	-->
  </system.web>
  <system.net>
    <mailSettings>
      <smtp from="sales@fabricsplus.com.au">
        <network
          host="mail.fabricsplus.com.au"
          port="25"
	  userName="sales@fabricsplus.com.au"
	  password="Pedro1"
        />
      </smtp>
    </mailSettings>
  </system.net>
  <appSettings>
    <!--   User application and configured property settings go here.-->
    <!--   Example: <add key="settingName" value="settingValue"/> -->
    <add key="connDB.ConnectionString" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\vhosts\fabricsplus.com.au\httpdocs\ASP\FPDB\dbFabricsPlus.mdb;Persist Security Info=False" />
  </appSettings>
</configuration>
Posted
Updated 24-Mar-22 21:12pm
Comments
Sandeep Mewara 2-Aug-20 6:45am    
Your XML looks fine to me. I believe the error is around the code you are using to load the XML. Share the code that you tried to load XML.
Member 14897481 2-Aug-20 8:58am    
it wont let me post the whole code...that's how it look when I paste it
Richard MacCutchan 2-Aug-20 9:12am    
If you have extra information then you should post it into your question, and put proper <pre> tags around the code. Use the Improve question link above to edit your question. And while you do that, please remove all those blank lines.
Sandeep Mewara 2-Aug-20 9:27am    
Can you just post the C# code where you are trying to read the XML?

Your XML validates OK using an online validator: so the most likely causes of the error are that your code didn't process the actual XML but something totally different, or corrupted the XML before it was processed.

Either way, we don't have any access to your code, particularly when it is running - which means we can't give you a solution.

So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you don't know how to use it then a quick Google for "Visual Studio debugger" should give you the info you need.

Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
 
Share this answer
 
Comments
Member 14897481 2-Aug-20 9:00am    
Hello,

This is the code. Thats not the entire thing because it wont let me paste the entire thing for some reason

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="ShoppingCartCheckout.aspx.vb" Inherits="FabricsPlusCom.ShoppingCartCheckout" EnableSessionState="True" %>
<%@ Register TagPrefix="uc1" TagName="ctrlShoppingCart" Src="ASP/WebuserControls/ctrlShoppingCart.ascx" %>



<title>Fabricsplus.com.au - Checkout
<asp:literal id="ltlPageTitle" runat="server"><asp:literal id="ltlMetaKeywords" runat="server"><asp:literal id="ltlMetaDescription" runat="server">














































<asp:label id="Label1" runat="server" font-underline="True" font-bold="True" font-size="Larger">FabricsPlus.com.au




 
<asp:label id="lblTotalProducts" runat="server" font-bold="True" forecolor="Yellow"> 
<asp:label id="lblProducts" runat="server" forecolor="Yellow"> products for
<asp:label id="lblAusDollar" runat="server" font-bold="True" forecolor="Yellow">Aus$ 
<asp:label id="lblTotalAmount" runat="server" font-bold="True" forecolor="Yellow">
<asp:label id="Label5" runat="server" forecolor="Yellow">Shipping costs:
<asp:label id="lblTotalShippingCosts" runat="server" font-bold="True" forecolor="Yellow">


<asp:label id="lblStep1MenuText" runat="server" forecolor="Yellow">Step 1: Personal details<asp:image id="imgStep1Check" runat="server" visible="False" imageurl="Images/check.gif"><asp:label id="lblStep2MenuText" runat="server" forecolor="Yellow"> Step 2: Payment<asp:image id="imgStep2Check" runat="server" visible="False" imageurl="Images/check.gif"><asp:label id="lblStep3MenuText" runat="server" forecolor="Yellow"> Step 3: Confirmation<asp:image id="imgStep3Check" runat="server" visible="False" imageurl="Images/check.gif">

<asp:label id="lblFinished" runat="server" font-bold="True" font-size="Medium" forecolor="Yellow" visible="False">Finished!

<asp:label id="lblPaymentChoice" runat="server" visible="False">
<asp:label id="lblStep" runat="server" visible="False">1









<asp:label id="lblStepTitle" runat="server" font-bold="True" font-size="Medium">Step 1: Personal details
<asp:label id="lblPageIntro" runat="server"> Welcome to the FabricsPlus.com.au checkout!














































PERSONAL INFORMATION:Name:<asp:textbox id="txtName" runat="server" width="190px">Address:<asp:textbox id="txtAddress" runat="server" width="190px" rows="3" textmode="MultiLine">Postcode:<asp:textbox id="txtPostcode" runat="server" width="190px">City:<asp:textbox id="txtCity" runat="server" width="190px">State:<asp:textbox id="txtState" runat="serv
<configuration>
<system.web>
<!-- DYNAMIC DEBUG COMPILATION
Set compilation debug="true" to insert debugging symbols (.pdb information)
into the compiled page. Because this creates a larger file that executes
more slowly, you should set this value to true only when debugging and to
false at all other times. For more information, refer to the documentation about
debugging ASP.NET files.
-->
<compilation defaultlanguage="vb" debug="true" targetframework="4.6">
<httpruntime targetframework="4.6">
<!-- CUSTOM ERROR MESSAGES
Set customErrors mode="On" or "RemoteOnly" to enable custom error messages, "Off" to disable.
Add <error> tags for each of the errors you want to handle.
-->
<customerrors mode="Off">
<!-- AUTHENTICATION
This section sets the authentication policies of the application. Possible modes are "Windows",
"Forms", "Passport" and "None"
-->
<authentication mode="Forms">
<forms loginurl="/Admin/Login.aspx">

<!-- AUTHORIZATION
This section sets the authorization policies of the application. You can allow or deny access
to application resources by user or role. Wildcards: "*" mean everyone, "?" means anonymous
(unauthenticated) users.
-->
<authorization>
<allow users="*">
<!-- Allow all users -->
<!-- <allow users="[comma separated list of users]"
="" roles="[comma separated list of roles]">
<deny users="[comma separated list of users]"
="" roles="[comma separated list of roles]">
-->

<!-- APPLICATION-LEVEL TRACE LOGGING
Application-level tracing enables trace log output for every page within an application.
Set trace enabled="true" to enable application trace logging. If pageOutput="true", the
trace information will be displayed at the bottom of each page. Otherwise, you can view the
application trace log by browsing the "trace.axd" page from your web application
root.
-->
<trace enabled="false" requestlimit="10" pageoutput="false" tracemode="SortByTime" localonly="true"> <!-- SESSION STATE SETTINGS
By default ASP.NET uses cookies to identify which requests belong to a particular session.
If cookies are not available, a session can be tracked by adding a session identifier to the URL.
To disable cookies, set sessionState cookieless="true".
-->
<sessionstate
mode="InProc"
="" cookieless="false" timeout="60">
<!-- GLOBALIZATION
This section sets the globalization settings of the application.
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=;Persist Security Info=False
D:\vhosts\fabricsplus.com.au\httpdocs\ASP\FPDB\dbFabricsPlus.mdb
Changed Text
-->
<globalization requestencoding="utf-8" responseencoding="utf-8">
<!-- <identity impersonate="true"> -->
<!--
<machinekey validationkey="50F768F66ED5CCA46CBF28C382D95C6BCD7BC696A74B47DCC17928736541DF95A7C94EAF4147D6F7B3C2BB44286FB99B54A7F71C77854ABEEF19252265216FB9" decryptionkey="8D97CB08D9D841D496615A7DB34C01F86E3256CB54734F9FC693B648B14333B5" validation="SHA1" decryption="AES">
-->

<system.net>
<mailsettings>
<smtp from="sales@fabricsplus.com.au">
<network
host="mail.fabricsplus.com.au"
="" port="25" username="sales@fabricsplus.com.au" password="Pedro1">



<appsettings>
<!-- User application and configured property settings go here.-->
<!-- Example: <add key="settingName" value="settingValue"> -->
<add key="connDB.ConnectionString" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\vhosts\fabricsplus.com.au\httpdocs\ASP\FPDB\dbFabricsPlus.mdb;Persist Security Info=False">

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900