5

The browser console was showing errors for woff font type. So, in the site's web.config I included this property and it was fixed.

<system.webServer>
......
......
 <staticContent>
  <mimeMap fileExtension=".woff" mimeType="application/font-woff"/>
 </staticContent>
</system.webServer>

But, I want to add this property via a patch. I created a config in the VS project /App_Config/Include/MySite.config as below and published:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <system.webServer>
      <staticContent>
        <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
      </staticContent>
    </system.webServer>
  </sitecore>
</configuration>

In the site's showconfig.aspx it is rendered as below, but the woff error in the console shows up.

<system.webServer patch:source="MySite.config">
 <staticContent>
  <mimeMap fileExtension=".woff" mimeType="application/font-woff"/>
 </staticContent>
</system.webServer>

Am I including the patch in the right way? Using Sitecore 8.0 with MVC

9

You can't patch configuration that are outside of Sitecore node section. To patch configuration outside Sitecore node I recommend you to use SlowCheetah.

Patching only works on the Sitecore configuration section. This is located in under /configuration/sitecore node section. Configuration in other sections of Web.config cannot be controlled through patching.

How to See the Result of Patching

Since the Sitecore configuration is the result of the merging of configuration from Web.config with a variable number of patch files, you cannot look at Web.config or any individual patch file in order to determine the configuration Sitecore is using. Sitecore includes an admin script to do this.

The script displays the results of the config file patching process.

http://[host]/sitecore/admin/ShowConfig.aspx

You can find SlowCheetah on below link :

https://visualstudiogallery.msdn.microsoft.com/69023d00-a4f9-4a34-a6cd-7e854ba318b5/view/Discussions/1

Getting started is really simple, just install this package. Then in the solution explorer you can easily add your config transform by right-clicking and selecting Add Transform.

enter image description here

After you add the transform you will notice a transform for each build configuration. enter image description here

You can place your customizations inside of the transform files, for example if you want to tweak app settings and connection strings you might use the syntax shown below.

When you build your applicatoin the files are transformed and dropped into the output directory. If you are transforming the app.config then when the file is transformed it will be renamed in the output directory as usual to ensure that your application picks it up at runtime.

For web projects the files are transformed when you publish or package your application.

You can also quickly preview your transform using the Preview Transform context menu on the transform file.

enter image description here enter image description here

  • 1
    Note that if upgrading Sitecore (as of 8.2.x) it will replace your web.config (creating backups). So you will need to go back in and drop in your web.config customizations, and/or update your local web.config copy with the updates. – James Skemp May 1 '17 at 21:11
2

<system.webServer> is not under <sitecore> node in web.config file.

You cannot patch it using Sitecore mechanisms.

Here is pretty much the same question asked on StackOverflow site: https://stackoverflow.com/questions/30768383/trouble-with-sitecore-web-config-patch-file

And as Matthew Dresser explains there, to change config outside of <sitecore> node, you need to to this either directly or using transformation mechanisms (like SlowCheetah - check Vlad's answer for the link).

And more about Sitecore web.config include files and patching: http://intothecore.cassidy.dk/2009/05/working-with-webconfig-include-files-in.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.