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

Shiva

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

72 Comments For This Post

  1. Naved Says:

    Thanks for the tip! I am a asp.net newbie, and this really helped me to get started with learning it.
    -Naved

  2. Henrik Says:

    Thanx, this helped me a lot :)

  3. Lucky Says:

    Thank you very much. It works

  4. Luke Says:

    Cheers worked.

  5. Jon Says:

    Thanks! This is a very clear and concise page and helped me out big time! Cheers!

  6. kali Says:

    Thank you very much! It worked…

  7. Navpreet Khurmi Says:

    thanks a lot. It really helped.

  8. Naveen Says:

    thanks man it really helped me
    great thinking

  9. d prince raja sunder manoj Says:

    This is very clear and it is working for me now.
    Thanks a lot!

  10. Bruce Says:

    On secured machines, this may also be caused if you’ve removed mappings for particular files in the IIS Manager. If this is happening, go into the IIS Manager, right-click on your web, choose properties. Then click the Home Directory tab and the Configuration button.

    Make sure the Application Extension for that particular extension is mapped to the aspnet_isapi.dll and at least the verbs “GET,POST” are in there.

  11. Rashmi Says:

    Thank you so much….very helpful tip…working for me now..thanks :)

  12. Vzar Says:

    I just google my problem and found this. Correct and perfect answer, thank you guy!

  13. amanda Says:

    thank you! as others have said, this works perfectly. :)

  14. Aswani Says:

    i am new to asp.net … i developed a website in VS in which I access an XML file ..i wanted it to run as a browser independent one . I wrote different codes for IE and other browser both the codes were running well individually but when i combine them … it works well in IE but it does not work in MOzilla and i get the above error. Please help me out …..

  15. sam_almeida Says:

    thanks a bunch!!

  16. nana Says:

    Thanks so much, it really help me!!

  17. Sop Says:

    I solved this problem, all my files were read only…and i unchecked read only…And it works..

  18. satya Says:

    I want to run an aspx file after uploading it to remote server. When i tried to run in browser, the same error is appearing. I didnt find any property in IIS manager of the server.Please help me.

  19. Nilesh Says:

    Thank you so much.

    It has solved my problem.

    Really Thanks from the heart.

  20. Masroor Says:

    Thanks i am asp.net developer and this problem is really troubling me

  21. Mexus Says:

    THX U wery much, real help for newbies

  22. Moataz Says:

    Great work man

  23. VISHAL PAREKH Says:

    thanks,i have solved my problem.

    this is excellent,not because u give solution,but u given solution of issue,and also why it happens.

    thank u again.great

  24. Ryan Says:

    Within the website’s properties, there’s a tab for ASP.NET. My ASP.NET version was blank, but 2.0.50727 was listed in the drop-down menu. Choosing this version and hitting apply worked for me.

  25. Ryan Says:

    There’s a tab for ASP.NET in the website properties within IIS. My ASP.NET version was blank, but 2.x existed in the drop-down menu. Choosing this version and pressing apply solved my problem (well, I get a different error, but one that’s my fault).

  26. orech Says:

    Cool stuff, thanks a lot, very helpful.

  27. vincent kasyoki -kenya Says:

    My boss was very angry at me.Thanks so much for the support.

  28. Aarti Says:

    Hey, thanks!!!!
    It worked!! :)

  29. Oves Khan Says:

    Thank you Sir
    it helps me a lot

  30. Anybody Says:

    Thank you very much.

  31. Preetam Says:

    hello,

    Thanks a lot for ur answer.. it helped me a lot.

  32. Carl Sposito Says:

    nice try..this did not work for me..any other possible causes?

  33. Me Says:

    Cheers, worked a treat!

  34. nikki Says:

    when i try to run my web with vs.net it works properly. And when i run it without vs.net this comes out. please help me. here is my email. siedexxx @ yahoo.com please send me ideas. i cant go on with my projects -_-

  35. Gaurav Ramesh Sharma Says:

    Thanks for this Tip!!
    It really worked.

  36. Bala Says:

    Thanks for help..

  37. vvvvvvvvv Says:

    Thanks for the tip! I am a asp.net newbie, and this really helped me to get started with learning it.

  38. disgruntledgiant Says:

    google brought me to yr spot and i don’t regret it.
    good work!

  39. Ashok Says:

    Thanks for all the efforts

  40. yvetty Says:

    thank you, it worked! just like carl, are there any other causes?

  41. Kelvin Says:

    Thanks, you save my day!!!

  42. ToniB Says:

    Thank you very much!!!
    I started to go nuts about this!

  43. Muhammad Ismail Says:

    Thanks a lot.

    I am really thankful keep it up to solve people’s problem God bless you and your team.

  44. Chipmunk Says:

    You are a god among gods. I spent hours manually trying to figure out what the hell was going on. Many thanks.

  45. Amit Says:

    Thanks a lot !!
    This problem suffered me a lot
    Thanks again :)

  46. Subri Says:

    I don’t know but i still get the error

  47. Umair cheema Says:

    Thank you….It really helped

  48. Annie Says:

    Thanks! I don’t understand it, but it’s fixed which is all I care about! Awesome!!!!

  49. Monica Says:

    Thank you very much. Most importantly u have mentioned the reason for the cause that is a great help.

  50. lethach Says:

    Thanks. But i see an error Server Application Unavailable

  51. Arvind Upadhyay Says:

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

  52. 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.

  53. raj warrier Says:

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

    Regards
    RAJ

  54. 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

  55. Steve Says:

    Thanks wrked like a charm..

  56. Nirmala Says:

    Thank you very much!!!!

  57. vikas Says:

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

  58. jacob Says:

    thanks a lot man…

  59. Garrett Says:

    thanks man…

  60. 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

  61. chanra shekhar Says:

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

  62. 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…….

  63. Nirupama Says:

    Thank you so much

  64. Yong Says:

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

  65. 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

  66. 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!

  67. 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)

  68. Najiya Says:

    Hi Shiva…

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

  69. paul Says:

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

  70. Clifford Says:

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

  71. moddar Says:

    Thank you very much
    go on

  72. mitesh Says:

    it really worked for me.. gr8 job…

Leave a Reply

Advertise Here

Photos from our Flickr stream

See all photos

Advertise Here