The element ‘system.web’ has invalid child element ‘defaultDocument’

asp.netasp.net-4.0visual studio 2012web.config

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"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <appSettings/>
  <system.web>

    <defaultDocument>
      <files>
        <clear />
        <add value="Defalut.aspx" />
      </files>
    </defaultDocument>

    <compilation debug="true" targetFramework="4.0"/>
    <httpRuntime/>
    <pages controlRenderingCompatibilityVersion="4.0"/>
    <machineKey/>
    <customErrors defaultRedirect="Error.aspx" mode="On"/>
  </system.web>
</configuration>

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?

Best Answer

"Defalut.aspx" is a definite yellow flag.

SUGGESTION:

  1. Just create a new dummy project with MSVS2012 (I don't have a copy handy, so I can't help you at the moment)

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

  3. Save a backup of your working web.config

  4. Try adding your "defaultDocument" section and see what happens.

  5. If it still doesn't work, please cut/paste:

    a) the exact section (as I presume you did above)

    b) the exact error message

ALSO:

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?