views:

473

answers:

3

When beginning a new web project, i'm always a bit worried about removing pieces of the web.config. It seems there are more entries than ever with Net 3.5 SP1.

Which bits of the .config do you delete for the following scenarios:

  • WCF Web Service, no Javascript support
  • Simple MVC Website

EDIT Can someone document a basic list of things left in and taken out of the web.config for a simple website?

+3  A: 

I usually just delete items from the web.config until things break -- a process of trial and error.

It's astonishing how much of web.config you can remove without affecting anything. It's gotten quite crufty in .NET 3.5.

Jeff Atwood
Especially in my WCF host web applications in IIS7, the web.config files are devoid of all of the standard cruft.
cfeduke
+1  A: 

Largely agree with Jeff that it is a process of trial and error as to what you can remove from the file.

In terms of tweaking the runtime and the http pipeline, it can often be a process of adding things to the web.config, in order to turn things off.

The out of the box configuration adds a lot of modules to the pipeline, depending on what you are doing, you may not need half of them.

Have come across a few articles on this on MSDN, and also this one http://www.codeproject.com/KB/aspnet/10ASPNetPerformance.aspx, by Omar from PageFlakes, which was the only one I could find in my (poorly organised) bookmarks, which is a good starting point on optimising the runtime.

seanb
A: 

Here is a stripped down Web.config i use for a simple WCF service

<?xml version="1.0"?>
<configuration>
    <system.web>
        <compilation debug="true">
          <assemblies>
            <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
          </assemblies>
        </compilation>
        <authentication mode="Windows" />
        <customErrors mode="RemoteOnly" defaultRedirect="error.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
    </system.web>
    <system.codedom>
      <compilers>
        <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
                  type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
          <providerOption name="CompilerVersion" value="v3.5"/>
          <providerOption name="WarnAsError" value="false"/>
        </compiler>
      </compilers>
    </system.codedom>
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="Service.ServiceBehavior" name="Service.Service">
        <endpoint address="" binding="basicHttpBinding" contract="Service.IService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Service.ServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

I removed a lot of extras especially the script modules which i won't require

Harry