Fix for ‘XML Parsing Error: not well-formed Line Number 1, Column 2′ Error

When you access an ASP.NET page in your browser, you may get an XML Parsing Error that says that the XML is not well formed. The error message also displays the page directive statement present in the 1st line of the .aspx file. First we will fix this error, then we will look at one possible reason why you may be getting this error in ASP.NET.

asp-net-xml-parsing-error-not-well-formed

Fix the ‘XML Parsing Error’

Click Start > Run, and type the following command depending on which ASP.NET framework is in use by the default web site in your IIS.

ASP.NET 2.0 Framework

%Windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i

ASP.NET 1.1 Framework

%Windir%\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -i

You should see a command window that is displayed briefly, that shows that ASP.NET is being installed. After the registration is successful, the window will be closed. register-asp-net-framework-with-iis

Now refresh the .aspx page that you got the XML Parser error for in the browser and your page should be rendered correctly.

Why did you get this error ?

I have seen this error happen to me in situations where I had installed IIS after the installing the .Net Framework. This make sense. If you install IIS after you install the .Net Framework, then the framework is not registered with IIS. So when a request for a .aspx page comes to IIS, it simply passes on the contents of the page as-is without processing it. So in effect, the browser receives the entire .aspx page’s code, tried to parse it as an XML file, encounters the parsing error at the second character in the page directive and stops.

Related: ASP.NET IIS Registration Tool

96 people commented!

  1. Arvind Upadhyay says:

    Xml Parsing error (error code 29) Line 21, column 2 of file

  2. A N Other says:

    This was really useful in solving the exact same problem. The “why did you get this error” made a whole lot of difference in understanding exactly how we got the error in the first place and how to get it fixed.
    Just for record, the software we were trying implement was relying on an earlier version of .net, so changing the version used in “Properties” of the relevant virtual folder was part of the problem. Followed by the reinstall as mentioned above.
    Much appreciated, thanks.

  3. raj warrier says:

    Open IIS .
    Select DefaultWebsite->Properties->ASP.NET Tab
    Then Select ASP.NET version from the Combobox.

    Regards
    RAJ

  4. ihsan says:

    i have asp.net 2 and IIS 5 and i got this problem and try all your solution i wrote the command and change the property in virtual directory and no benefit then i uninstall vs2005 and IIS5 then install them again starting with IIS5 then vs2005
    and no benefit i dont know what to do please

  5. Steve says:

    Thanks wrked like a charm..

  6. Nirmala says:

    Thank you very much!!!!

  7. vikas says:

    first it didn’t work for me but i reinstall the iis and then register it. it works. :)
    thanks

  8. jacob says:

    thanks a lot man…

  9. Garrett says:

    thanks man…

  10. Pankaj says:

    Thanx
    its working fine, but my servername gets changes e.g
    My servername is ABC it makes to “ABCASPNET” after publishing web site

  11. chanra shekhar says:

    fabulous…..fantastic…….u rocked…man….maza aa gya..

  12. RAZA says:

    Wow!!
    Thank you so much!!
    My whole team was in trouble from last 2 days with it, now i have fixed it with your help.
    Keep on man!
    it’s really a good helpful post………..
    Thank you so much again…….

  13. Nirupama says:

    Thank you so much

  14. Yong says:

    But I have installed .NET 3.5
    In such case what can i do?

  15. Shiva says:

    @Yong. According to a response in this thread, it seems that “ASP.NET 3.5 runs on top of ASP.NET 2.0, almost like a service pack”.

    Also, from this MSDN Article on aspnet_regiis.exe specific to .Net 3.5, it is still saying that you should register the 2.x aspnet_regiis.exe version.

    So I would suggest you try this out first and see if that helps !

    -Shiva

  16. Yong says:

    You’re right
    but every time i must use that command
    what can i do?
    I’ll appreciate if you suggest better way!
    Thanks!

  17. Shiva says:

    The registration should be a 1 time thing. Are you having to do it every time ?

    If yes, then can you try adding the Compilers section / Compiler directives in your web.config (see this thread for the actual code to add)

  18. Najiya says:

    Hi Shiva…

    Thanks a lot… it helped ..!
    appreciate the way you explained….

  19. paul says:

    I don’t normally leave message, but this time I must say thank you very much

  20. Clifford says:

    Thanks A Ton !!
    U Gave Th Solution In Best Possible Way…
    Thanks A Ton..

  21. moddar says:

    Thank you very much
    go on

  22. mitesh says:

    it really worked for me.. gr8 job…

  23. mustafa says:

    thank you very much you are help me alot

  24. Rajeev says:

    What coomand should give for asp.net 3.5

  25. kishor says:

    It worked only once. Next time when i tried open window still problem is seen. i tried installing asp.net still same problem persist

  26. Shiva says:

    maybe restarting IIS might help?

  27. K.Mohan Kumar says:

    The above article was very much helpful for me..I did it…

  28. Grigorian says:

    I didn’t quite understand, what if i publish my website to the web, and a person trying to view it has neither IIS nor .net framework installed in his computer… will he be unable to view my site, or it doesn’t metter…

  29. it doesn’t matter. IIS and .net is on the server side, on the webhost, not on the client side :)

  30. Reddygaru says:

    thanks a lot issue is fixed

  31. uttam says:

    Well its a good article to solve the problem for a single PC only . But how can solve the problem for remote server?

  32. rober says:

    Why did you get this error ?

    I have seen this error happen to me in situations where I had installed IIS after the installing the .Net Framework. This make sense. If you install IIS after you install the .Net Framework, then the framework is not registered with IIS. So when a request for a .aspx page comes to IIS, it simply passes on the contents of the page as-is without processing it. So in effect, the browser receives the entire .aspx page’s code, tried to parse it as an XML file, encounters the parsing error at the second character in the page directive and stops.

  33. Nathan says:

    It really works! Thanks.

  34. Rahul says:

    Really life saver solution for me. Big Big Big thanks….

  35. Sheikh Zubayr says:

    This worked like a charm. Thank you sir.
    Now i am facing another problem i.e. the page is not able to find its master page on the server even though it there. Please help.

  36. samir says:

    worked well. thanks you!!

  37. kranthi says:

    Can you send me why i get this error? and how to solve it.

    XML Parsing Error: not well-formed
    Location: file:///C:/Documents%20and%20Settings/chaitu/My%20Documents/Visual%20Studio%202008/Projects/WcfServiceLibrary2/WcfServiceLibrary2/Service.svc
    Line Number 1, Column 2:
    -^

  38. sagar handore says:

    Register iis with the version of .net framework (.net 4.0 or .net 3.5 etc.)

    a. Find aspnet_regiis.exe for the version you want to install . for example C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319

    b. aspnet_regiis –i ( it will register iis version)

    c. aspnet_regiis -k W3SVC

    ( it will Remove all scriptmaps to any version of ASP.NET from the specified path, recursively (not supported on Windows Vista and higher versions).

    d. aspnet_regiis -s W3SVC

    (it will Install scriptmaps for this version at the specified path, recursively

  39. sheetal says:

    It’s not working in my case.after Register iis with the version of .net framework (.net 4.0 or .net 3.5 )
    Still that error is coming
    Please Help me out

  40. Anish Kumar says:

    Thanks a lot…its working for me…

  41. Stanley says:

    Thumbs up!
    You guys are great…
    Many thanks.

  42. Hi I get that error in blog spot
    Error parsing XML, line 11, column 2: The value of attribute “content” associated with an element type “null” must not contain the ‘<' character.

    Please feedback how can i fix it

  43. Ali Meyad says:

    thank you for help

  44. Indu says:

    thanku

  45. hodsJaddy says:

    Before choosing your health insurance plan, you may want to have a look at both government and native laws and regulations relating to health care insurance. Usually it is extremely normal info, but arming your self with knowledge before speaking with an agent can make sure that you aren’t used good thing about by a realtor hunting for the best payment. Among the big enemies of yeast infection is garlic herb. Like a home cure, there exists practically nothing greater. Tend not to use uncooked garlic herb, but get some garlic clove pills and put to the vaginal canal every couple of several hours for a few soothing alleviation. Read the label of the garlic herb tabs and just use the ones that are natural and all-natural. Kneading Vaseline to your cuticles may help both your hands in lots of ways. It would have the pores and skin much more hydrated and it will surely also encourage your fingernails or toenails to develop a little more rapidly. Accomplish this once weekly every week and you are certain to view a major difference in the appearance of both your hands and nails. It is best to review your regular monthly visa or mastercard assertions carefully and check out any errors or discrepancies. If you discover something which is completely wrong, advise your credit card company in composing, so that you have evidence that you simply aimed to speak to them about the problem. This will keep your funds in great order. Should you spend lots of time removing vouchers, check with the clerk at the store when you could subscribe to a course to have them mailed for you. This may decrease the time which you spend, as possible possess the vouchers that you desire probably the most at your fast convenience. Do not permit couponing overpower you. If you have observed the intense couponers on tv reality displays, you know how significantly it could go. Even when that is pulling you in, commence slow-moving. Attempt to help save just 5 various money away your normal expenditures the 1st week. Repeat your ability to succeed for a lot of days just before establishing your points of interest better.

Leave a Reply