Victor Rodrigues
Victor Rodrigues

Reputation: 11711

Is there a way to not use the traditional .config files for ASP.NET?

I find Web.config xml pretty verbose.

Do you know any initiative made in the way to enable cleaner config files, using YAML, or .rb files, anything that could suck less?

EDIT: I already know that FubuMVC web framework, built on top of ASP.NET, tries to reduce a lot the amount of XML you need to put in that file in order to work properly. But it is still pretty ugly, I find it unnecessary:

<?xml version="1.0"?>

<configuration>

  <appSettings/>
  <connectionStrings/>

  <system.web>
    <compilation debug="true">
      <assemblies>
        <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      </assemblies>
    </compilation>
    <authentication mode="None" />
    <customErrors mode="RemoteOnly"/>
    <pages>
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </controls>
    </pages>
    <httpModules>
      <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </httpModules>
    <httpHandlers>
    </httpHandlers>
  </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.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="UrlRoutingModule" />
      <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
    <handlers>
      <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </handlers>
  </system.webServer>

</configuration>

This is the bare minimum amount of XML you need to make things run, really bad. Many things above could just be the default.

Upvotes: 2

Views: 170

Answers (2)

Tundey
Tundey

Reputation: 2965

The minimum web.config can be much more smaller than that. As of .NET 4.0, the smallest is:

<?xml version="1.0"?> 
<configuration>
  <system.web> 
     <compilation targetFramework="4.0" /> 
  </system.web> 
</configuration>

Source: http://msdn.microsoft.com/en-us/library/s57a598e.aspx

Upvotes: 1

Carson63000
Carson63000

Reputation: 4232

My recommendation would be to leave Web.config alone as much as possible, and split your own configuration settings off into separate files.

e.g.

  <connectionStrings configSource="Configs\ConnectionStrings.config"/>
  <appSettings configSource="Configs\AppSettings.config"/>

Instead of having your connection strings and app settings inside Web.config.

Upvotes: 6

Related Questions