Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Data at the root level is invalid. Line 1, position 1.

Data at the root level is invalid. Line 1, position 1.

Scheduled Pinned Locked Moved C#
visual-studiohelpcsharphtmlsysadmin
7 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ASPnoob
    wrote on last edited by
    #1

    Hi all, I have a web service that used to work but stopped working when I migrated to a new computer. The new computer comes with Windows 8.1 and IIS Express. I made sure that I got everything I need by selecting every option under IIS. I installed the same version of Visual studio (VS 2012) on the new machine and tried to run the same web app I had in the old machine. When I click a button which makes a call to my web service, nothing happens. I found out through Fidler2 that the problem was

    "Data at the root level is invalid. Line 1, position 1."

    I have searched online but none matched my situation. Basically all I'm trying to do is send text from a regular html page in the form of JSON to the web service. Then the web service will modify a text file on the server using the text it received. I know the code in the web service works because I called it directly in Visual Studio and it worked fine. Please suggest a way to fix this problem, thanks in advance

    P 1 Reply Last reply
    0
    • A ASPnoob

      Hi all, I have a web service that used to work but stopped working when I migrated to a new computer. The new computer comes with Windows 8.1 and IIS Express. I made sure that I got everything I need by selecting every option under IIS. I installed the same version of Visual studio (VS 2012) on the new machine and tried to run the same web app I had in the old machine. When I click a button which makes a call to my web service, nothing happens. I found out through Fidler2 that the problem was

      "Data at the root level is invalid. Line 1, position 1."

      I have searched online but none matched my situation. Basically all I'm trying to do is send text from a regular html page in the form of JSON to the web service. Then the web service will modify a text file on the server using the text it received. I know the code in the web service works because I called it directly in Visual Studio and it worked fine. Please suggest a way to fix this problem, thanks in advance

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      Sounds like mal-formed XML. Have a look and give an example.

      A 1 Reply Last reply
      0
      • P PIEBALDconsult

        Sounds like mal-formed XML. Have a look and give an example.

        A Offline
        A Offline
        ASPnoob
        wrote on last edited by
        #3

        Hi, thanks for responding. I am not reading or writing any XML. In fact even after removing all the code in the webmethod of my webservice except for the return statement

        return "Success!";

        I still get the same error.

        D P 2 Replies Last reply
        0
        • A ASPnoob

          Hi, thanks for responding. I am not reading or writing any XML. In fact even after removing all the code in the webmethod of my webservice except for the return statement

          return "Success!";

          I still get the same error.

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Yes you are, you just don't know it. Have a look in your web.config file and you'll probably file the XML in there is messed up.

          A guide to posting questions on CodeProject

          Click this: Asking questions is a skill. Seriously, do it.
          Dave Kreskowiak

          A 1 Reply Last reply
          0
          • A ASPnoob

            Hi, thanks for responding. I am not reading or writing any XML. In fact even after removing all the code in the webmethod of my webservice except for the return statement

            return "Success!";

            I still get the same error.

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            JSON is XML, is it not?

            A 1 Reply Last reply
            0
            • D Dave Kreskowiak

              Yes you are, you just don't know it. Have a look in your web.config file and you'll probably file the XML in there is messed up.

              A guide to posting questions on CodeProject

              Click this: Asking questions is a skill. Seriously, do it.
              Dave Kreskowiak

              A Offline
              A Offline
              ASPnoob
              wrote on last edited by
              #6

              Hi, thanks for replying. I validated the webconfig file and it is actually valid. It turns out the problem was in the url in my ajax. I copied and paste the webservice url from Visual Studio and it appears a couple of letters were automatically tacked onto the url between the webservice name and the webmethod name. Once I removed the extra letters everything worked fine.

              1 Reply Last reply
              0
              • P PIEBALDconsult

                JSON is XML, is it not?

                A Offline
                A Offline
                ASPnoob
                wrote on last edited by
                #7

                Hi, thanks for replying. You got me thinking for a minute there with your question

                "JSON is XML, is it not?"

                According to json.org JSON is not XML, it's an alternative to XML. Also the website

                http://searchwindevelopment.techtarget.com/definition/JSON-Javascript-Object-Notation

                says the following:

                "JSON was originally based on the Javascript programming language and was introduced as the page scripting language for the Netscape Navigator Web browser"

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups