Title: The element 'system.web' has invalid child element 'defaultDocument'
Tags: asp.net;web-config;asp.net-4.0;visual-studio-2012
Question: I'm training my web.config to recognize what the best default file is. According to my host it's supposed to look like in the listing below.
<?xml version="1.0"?&gt;
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
--&gt;
<configuration&gt;
<appSettings/&gt;
<system.web&gt;
<defaultDocument&gt;
<files&gt;
<clear /&gt;
<add value="Defalut.aspx" /&gt;
</files&gt;
</defaultDocument&gt;
<compilation debug="true" targetFramework="4.0"/&gt;
<httpRuntime/&gt;
<pages controlRenderingCompatibilityVersion="4.0"/&gt;
<machineKey/&gt;
<customErrors defaultRedirect="Error.aspx" mode="On"/&gt;
</system.web&gt;
</configuration&gt;
The problem is that VS2012 (Express) marks it blue and claims the error in the subject. First i thought that i could upload it as it is and by brute force make the server to like the file but it then got angry and spat out the following
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
As i read the error message it says that: "The configuration section 'defaultDocument' cannot be read because it is missing a section declaration."
I've done my homework and found the article below but due to the limitation in my situation (e.g. i need to manually upload the web.config file and i can't run any scripts on the server of my hosting company), it was to no avail.
How do i kill this little problem?

Here is the accepted answer: "Defalut.aspx" is a definite yellow flag.
SUGGESTION:
Just create a new dummy project with MSVS2012 (I don't have a copy handy, so I can't help you at the moment)
Cut and paste the auto-generated "web.config" into your project and verify that it works.
If it doesn't, make ONLY those MINIMAL changes needed to get a clean compile/execute.
Save a backup of your working web.config
Try adding your "defaultDocument" section and see what happens.
If it still doesn't work, please cut/paste:
a) the exact section (as I presume you did above)
b) the exact error message
Q: It now fails in BOTH your MSVS2012 (running locally) AND your target web server, correct?
Q: Are you sure the target web server is ASP.Net 4.0 capable?
Comment for this answer: Cudos on the misspelling detection. Good eyes!
Comment for this answer: I did as you asked (no changes needed to be done) and made it work with the "fresh" version of web.config. Then i added the defaultDocument tag and got the message that i'll paste in in the next comment.
Comment for this answer: The element 'system.web' has invalid child element 'defaultDocument'. List of possible elements expected:
Comment for this answer: 'anonymousIdentification, authentication, authorization, browserCaps, clientTarget, compilation, customErrors, deployment, deviceFilters, fullTrustAssemblies, globalization, healthMonitoring, hostingEnvironment, httpCookies, httpHandlers, httpModules, httpRuntime, identity, machineKey, membership, mobileControls, pages, partialTrustVisibleAssemblies, processModel, profile, roleManager, securityPolicy, sessionPageState, sessionState, siteMap, trace, trust, urlMappings, webControls, webParts, webServices, xhtmlConformance, caching'. C:\...\Web.config
Comment for this answer: It also lists an error message which i mentioned in the comment below. It says: "Unrecognized configuration section system.web/defaultDocument. C:\...\Web.config" (the ellipsis is there for readibility reasons)

Here is another answer: You config looks correct but the error occurs because it cannot find the file that is mean to be the default document for all your website folders
So please replace "Defalut.aspx" with he correct spelling of the file in the below xml
<defaultDocument&gt;
<files&gt;
<clear /&gt;
<add value=*"Defalut.aspx"* /&gt;
</files&gt;
</defaultDocument&gt;
Comment for this answer: That's definitely a problem area BUT i don't think it's the cause to my problem as the error message complains about the tag not being recognized, rather than the file not being found.
Comment for this answer: In fact VS states very clearly that "Unrecognized configuration section system.web/defaultDocument." plus i have corrected the spelling and the error remains.

Here is another answer: Late to the party, I know, but for anybody still with a similar problem, I don't believe this has anything to do with the spelling of the default page name (that will probably just give a 404 when it's accessed).
The real issue is that the defaultDocument section should actually be under system.webServer, not system.web.  See defaultDocument Element for more info.
So your sample config file should look something like:
<?xml version="1.0"?&gt;
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
--&gt;
<configuration&gt;
<appSettings/&gt;
<system.web&gt;
<compilation debug="true" targetFramework="4.0"/&gt;
<httpRuntime/&gt;
<pages controlRenderingCompatibilityVersion="4.0"/&gt;
<machineKey/&gt;
<customErrors defaultRedirect="Error.aspx" mode="On"/&gt;
</system.web&gt;
<system.webServer&gt;
<defaultDocument&gt;
<files&gt;
<clear /&gt;
<add value="Defalut.aspx" /&gt;
</files&gt;
</defaultDocument&gt;
</system.webServer&gt;
</configuration&gt;

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 3, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2012:00:07/15/12', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<asp.net><web-config><asp.net-4.0><visual-studio-2012>', 'Title': "The element 'system.web' has invalid child element 'defaultDocument'", 'ViewCount': 6079, 'id': 11495074, 'user_AboutMe': '<p>A self taught code monkey since the age of 10 when I got my first computer, the coolest Atari 65XE. Later on, a mathematics and computer science student at a university with a lot of side-studies in philosophy, history, Japanese etc. Today, a passionate developer with focus on web related technology from UX, through JS/TS to C# with a touch of SQL.</p>\n\n<p>Motto:<br>\nA <strong>lousy</strong> programmer knows how to create problems.<br>\nA <strong>good</strong> programmer knows how to solve problems.<br>\nA <strong>great</strong> programmer knows how to avoid <strong><em>them</em></strong>. (Get the double meaning?)</p>\n\n<pre><code>Works at: http://kentor.se  \nBlogs at: http://konradviltersten.wordpress.com  \nLives at: http://viltersten.somee.com\n</code></pre>\n', 'user_AccountId': 1656397.0, 'user_DisplayName': 'Konrad Viltersten', 'user_Reputation': 33287.0, 'user_Views': 8271.0, 'user_id': 1525840.0}}