The Configuration Section Cannot Contain a Cdata or Text Element Error in Web. Config File

I am getting an error while executing the application on server "The configuration section cannot contain a CDATA or text element(web.confing line 149) the error lines are as follows,

<location path="admin">
   <system.web>
    <authorization>             
        <allow roles="Admin"/>
        <deny users="*"/>;
    </authorization>
   </system.web>
</location>

Pleae help me in this error.

9 Answers

You have a semicolon in front of

<deny users="*"/>

This semicolon is not allowed and is the reason you are getting that error.

4

Make sure there's no stray character in the configuration file. It can be as "harmless" as a misplaced "-->" or extra ." or anything really minor.

0

Usually this error comes when there is invalid syntax in web config file

1

Avoid stray characters and spaces in web-config tags. I was doing everything right but my issue was I was having spaces which caused the issue.

This error happens only when some wrong code or garbage code ingected mistakenly inside your config file like sometime mistakenly you missed to remove semicolon or wrong keyword inserted which is not accepted by config file you just need to read your file properly and after removing garbage code it will start working File is not showing compile time error but it will show runtime error like this.

I've encountered this issue while copying the entire connection settings from Sticky Notes to the Machine.config file. I tried through the .config file, if there was any "S" characters available while saving the file. The real issue was as I stated above. Resolution:: Instead of copying the connection settings from Sticky Notes to the .config files, I've copied the settings to a "Notepad" and then copied to .config and IT WORKED !!!

Even I came across the same issue till I corrected some Semantic errors

Before:- " ( double quotes at the last)

After:- (double quotes at the last was removed)

After making the changes specflow worked fine for me.

I had a similar error and it turned out I had to replace the spaces at the beginnings of lines with actual tabs. Don't know why, but that worked.

You may have unusual characters in you string like "\n" that you don't normally see in Visual Studio or NotePad++. Copy that in a simple text editor (like basic NotePad) and copy back to your file.

That fixed the issue for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest