Hasitha Shan
Hasitha Shan

Reputation: 2980

Cannot host website with system.web.extensions

I am developing an .net 4.0 web application where I host it on IIS. The application was successfully hosted several times without the use of <system.web.extensions> in web.config file.

The application gets published without any errors, but when I try to host it using IIS and try to enable Directory Browsing it gives out the error The configuration section system.web,extensions cannot be read because its missing a section declaration. I've already set it up as .net 4.0 application from the application pool but still gives the error.

Following is my web.config file,

  <?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>
    <system.web>
      <compilation debug="true" targetFramework="4.0">
        <assemblies>
          <add assembly="MySql.Data, Version=6.5.4.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
          <add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        </assemblies>
      </compilation>
      <httpRuntime requestValidationMode="2.0" executionTimeout="1000" maxRequestLength="2147483647" />
    </system.web>
    <system.web.extensions>
      <scripting>
        <webServices>
          <jsonSerialization maxJsonLength="2147483647">
          </jsonSerialization>
        </webServices>
      </scripting>
    </system.web.extensions>
  </configuration>

May I know what i'm doing wrong here..this is such a headache and I've tried most of the resources online but all suggest to set the application pool to .net 4.0 which I have already done..

Many thanks for the help :)

Upvotes: 4

Views: 18167

Answers (3)

Bronek
Bronek

Reputation: 11245

If you upload 4.0 application on IIS with app pool which is set for 2.0 - 3.5 Integrated Pipeline then you will see the error about missing a section declaration for extension.

You need to set on IIS the app pool for 4.0-4.5 Integrated Pipeline.

Upvotes: 3

Kevin M
Kevin M

Reputation: 5506

You can solve the issue by adding following configuration setting in webconfig file

<configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
        <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
          <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
        </sectionGroup>
      </sectionGroup>
    </sectionGroup>
  </configSections>

Upvotes: 1

Aron
Aron

Reputation: 15772

<configuration>
  <configSections>
    <section name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup" />
  </configSections>
</configuration>

Add this to the configuration sections. Its weird that it isn't defaulted in the applicationHost.config

Upvotes: 10

Related Questions