Hell.Bent
Hell.Bent

Reputation: 1677

WCF Web.config - The configuration section 'system.webserver' cannot be read because it is missing a section declaration

I'm on Visual Studio 2010 and Target is 4.0. What's wrong with this web.config?

I'm getting 500 error on local web server: The configuration section 'system.webserver' cannot be read because it is missing a section declaration

<?xml version="1.0"?>
<configuration>
    <system.web>
        <compilation debug="true" targetframework="4.0">
            <authentication mode="None">
            </authentication>
        </compilation>
    </system.web>
    <system.webserver>
        <modules runallmanagedmodulesforallrequests="true">
        </modules>
    </system.webserver>
    <system.servicemodel>
        <servicehostingenvironment aspnetcompatibilityenabled="true">
            <standardendpoints>
                <webscriptendpoint>
                    <standardendpoint crossdomainscriptaccessenabled="true">
                    </standardendpoint>
                </webscriptendpoint>
            </standardendpoints>
        </servicehostingenvironment>
    </system.servicemodel>
</configuration>

It's giving me these warnings in VS:

Warning 1 p:\jcp\WCF1\WCF1\Service1.svc: ASP.NET runtime error: Unrecognized configuration section system.webserver. (p:\jcp\WCF1\WCF1\web.config line 9) p:\jcp\WCF1\WCF1\Service1.svc 1 1 WCF1

Warning 2 The 'targetframework' attribute is not allowed. p:\jcp\WCF1\WCF1\Web.config 4 29 WCF1

Warning 3 The element 'compilation' has invalid child element 'authentication'. List of possible elements expected: 'assemblies, buildProviders, codeSubDirectories, expressionBuilders, folderLevelBuildProviders'. p:\jcp\WCF1\WCF1\Web.config 5 5 WCF1

I've set my project to use local IIS and created on virtual. My client is Windows 7 pro with iis7 and the apppool for the folder is set to 4.0. Do I need .net 3.5 installed on the client?

Upvotes: 3

Views: 15685

Answers (2)

bresleveloper
bresleveloper

Reputation: 6070

i too had this for a spelling mistake, took me a couple of times to see that i missed the 'n' in environment, worth to put the entire file in a VS proj to let it test it

Upvotes: 1

John Hoerr
John Hoerr

Reputation: 8025

There are a couple of issues that I think might account for the errors you're seeing:

  1. Web.configs are case senstive. You'll need to camel-case your text (e.g. system.webServer, targetFramework, system.serviceModel.)
  2. system.web.authentication is a peer of system.web.compilation, and not a child of it.

Upvotes: 9

Related Questions