Sitecore Web.config修补程序文件的问题

时间:2015-06-10 22:26:49

标签: sitecore

我正在尝试“修补”Sitecore web.config,但我对如何向文件添加新项目感到困惑。下面的文件加载正常,直到它到达httpErrors行。在那里,我得到:

  

System.Xml.XmlException:'Element'是无效的XmlNodeType。

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
<sitecore>
<settings>
<setting name="DisableBrowserCaching">
    <patch:attribute name="value">false</patch:attribute>
</setting>
<setting name="Login.RememberLastLoggedInUserName">
    <patch:attribute name="value">false</patch:attribute>
</setting>
<setting name="Login.DisableAutoComplete">
    <patch:attribute name="value">true</patch:attribute>
</setting>
<setting name="Login.DisableRememberMe">
    <patch:attribute name="value">true</patch:attribute>
</setting>
</settings>
</sitecore>
<system.webserver>
<httpErrors errorMode="DetailedLocalOnly" />
<httpProtocol allowKeepAlive="true">
            <customHeaders>
                <remove name="X-Powered-By" />
            </customHeaders>
        </httpProtocol>
        <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
            <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
            <dynamicTypes>
                <add mimeType="text/*" enabled="true"/>
                <add mimeType="message/*" enabled="true"/>
                <add mimeType="application/javascript" enabled="true"/>
                <add mimeType="application/javascript; charset=utf-8" enabled="true"/>
                <add mimeType="application/json" enabled="true" />
                <add mimeType="application/json; charset=utf-8" enabled="true" />
                <add mimeType="application/x-javascript" enabled="true"/>
                <add mimeType="*/*" enabled="false"/>
            </dynamicTypes>
            <staticTypes>
                <add mimeType="text/*" enabled="true"/>
                <add mimeType="message/*" enabled="true"/>
                <add mimeType="application/javascript" enabled="true"/>
                <add mimeType="application/javascript; charset=utf-8" enabled="true"/>
                <add mimeType="application/json" enabled="true" />
                <add mimeType="application/json; charset=utf-8" enabled="true" />
                <add mimeType="application/x-javascript" enabled="true"/>
                <add mimeType="*/*" enabled="false"/>
            </staticTypes>
        </httpCompression>
        <urlCompression doStaticCompression="true" doDynamicCompression="true" dynamicCompressionBeforeCache="false"/>
        <staticContent>
            <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00"/>
            <!-- SETUP MIME TYPES FOR VIDEOS, SOUND, AND FONTS -->
            <remove fileExtension=".mp4" />
            <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
            <remove fileExtension=".m4v" />
            <mimeMap fileExtension=".m4v" mimeType="video/m4v" />
            <remove fileExtension=".ogg" />
            <mimeMap fileExtension=".ogg" mimeType="video/ogg" />
            <remove fileExtension=".ogv" />
            <mimeMap fileExtension=".ogv" mimeType="video/ogg" />
            <remove fileExtension=".webm" />
            <mimeMap fileExtension=".webm" mimeType="video/webm" />
            <remove fileExtension=".oga" />
            <mimeMap fileExtension=".oga" mimeType="audio/ogg" />
            <remove fileExtension=".spx" />
            <mimeMap fileExtension=".spx" mimeType="audio/ogg" />
            <remove fileExtension=".svg" />
            <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
            <remove fileExtension=".svgz" />
            <mimeMap fileExtension=".svgz" mimeType="image/svg+xml" />
            <remove fileExtension=".eot" />
            <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
            <remove fileExtension=".otf" />
            <mimeMap fileExtension=".otf" mimeType="font/otf" />
            <remove fileExtension=".woff" />
            <mimeMap fileExtension=".woff" mimeType="application/woff" />
            <remove fileExtension=".woff2" />
            <mimeMap fileExtension=".woff2" mimeType="application/woff2" />
        </staticContent>
<modules runAllManagedModulesForAllRequests="false">
            <remove name="BundleModule" />
            <add type="System.Web.Optimization.BundleModule" name="BundleModule" />
        </modules>
<rewrite>
<rules>
<rule name="Remove WWW" patternSyntax="Wildcard" stopProcessing="true" enabled="true">
    <match url="*"/>
    <conditions>
                <add input="{CACHE_URL}" pattern="*://www.*"/>
    </conditions>
    <action type="Redirect" url="{C:1}://{C:2}" redirectType="Permanent"/>
</rule>
<rule name="Remove Trailing Slash" stopProcessing="true" enabled="true">
    <match url="(.*)/$"/>
        <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
    </conditions>
    <action type="Redirect" url="{R:1}"/>
</rule>
</rules>
<outboundRules>
<rule name="Remove ETag">
        <match serverVariable="RESPONSE_ETag" pattern=".+" />
        <action type="Rewrite" value="" />
</rule>
</outboundRules>
</rewrite>
<applicationInitialization remapManagedRequestsTo="Startup.htm" skipManagedModules="true">
    <add initializationPage="/default.aspx" />
</applicationInitialization>
</system.webserver>
<system.web>
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
        </dependentAssembly>
        <dependentAssembly>
            <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
        </dependentAssembly>
</assemblyBinding>
</runtime>
<system.serviceModel>
    <basicHttpBinding>
        <binding name="SitecoreApplicationCenter" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:20:00" sendTimeout="00:05:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="10000000" maxBufferPoolSize="524288" maxReceivedMessageSize="10000000" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
            <readerQuotas maxDepth="32" maxStringContentLength="10000000" maxArrayLength="10000000" maxBytesPerRead="10000000" maxNameTableCharCount="10000000" />
            <!--<security mode="Transport"/>-->
        </binding>
    </basicHttpBinding>
    <client>
    </client>
</system.serviceModel>
</configuration>

添加所有这些新属性的正确语法是什么?

2 个答案:

答案 0 :(得分:5)

Sitecore配置文件修补仅适用于sitecore部分中的配置设置。

要修改system.webserver/httpErrors,您需要直接修改web.config,或使用其他配置修补系统,例如web.config transformations

答案 1 :(得分:0)

只有<sitecore>元素下的配置项可用于修补。不幸的是,其他web.config修改需要直接完成。