1

当开始一个新的 web 项目时,我总是有点担心删除 web.config 的片段。Net 3.5 SP1 的条目似乎比以往任何时候都多。

对于以下情况,您会删除 .config 的哪些位:

  • WCF Web 服务,不支持 Javascript
  • 简单的 MVC 网站

编辑 有人可以记录一个简单网站的 web.config 中留下和取出的基本列表吗?

4

3 回答 3

4

我通常只是从 web.config 中删除项目,直到事情破裂——这是一个反复试验的过程。

令人惊讶的是,您可以在不影响任何内容的情况下删除多少 web.config。它在 .NET 3.5 中变得相当糟糕。

于 2008-11-06T01:17:46.993 回答
1

很大程度上同意 Jeff 的观点,即对于可以从文件中删除的内容,这是一个反复试验的过程。

在调整运行时和 http 管道方面,它通常是一个向 web.config 添加东西的过程,以关闭这些东西。

开箱即用的配置为管道添加了很多模块,根据您的工作,您可能不需要其中的一半。

在 MSDN 上遇到过几篇关于此的文章,还有一篇http://www.codeproject.com/KB/aspnet/10ASPNetPerformance.aspx由 PageFlakes 的 Omar 撰写,这是我在我的(可怜的有组织的)书签,这是优化运行时的一个很好的起点。

于 2008-11-06T03:33:06.733 回答
0

这是我用于简单 WCF 服务的精简 Web.config

<?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>

我删除了很多额外的东西,尤其是我不需要的脚本模块

于 2009-02-03T05:13:48.557 回答