A bit of background

I was working on a site which needed to use SVGs.

I had created a media picker to choose an SVG from a folder in the Umbraco backoffice.

The site I was working on, had the media stored in azure blob storage.

It was running Umbraco 7.13.2 so SVGs were supported but it wasn't loading my SVGs.

The strange thing was, if I deleted the web.config file from the media folder, the SVGs would load.

This was the web.config file in the media folder:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <clear />
      <add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
    </handlers>
  </system.webServer>
</configuration>

I reached out on the Umbraco Forum and the Community Slack channel and Jeavon from Crumpled Dog gave me the answer.

The Solution

The solution was to add this line to the web.config file:

<add name="StaticFileHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.StaticFileHandler" />

But why?

I already had this set for the media location in my main web.config file so why did I need to set it again in this one?

The reason was because in the media web.config file, it was clearing all of the handlers first and then adding the StaticFile one. Meaning that any handlers that had been set in the main web.config file would be cleared first.

So the full web.config file in the media folder should look like this:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <clear />
            <add name="StaticFileHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.StaticFileHandler" />
            <add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
        </handlers>
    </system.webServer>
</configuration>

Thanks to Jeavon for giving me the answer and for helping me work out why it worked if I deleted the web.config file.

Want to thank me?

If I've helped you out and you want to thank me, why not buy me a coffee?

Buy me a coffee

About the author

Paul Seal

Umbraco MVP and .NET Web Developer from Derby (UK) who specialises in building Content Management System (CMS) websites using MVC with Umbraco as a framework. Paul is passionate about web development and programming as a whole. Apart from when he's with his wife and son, if he's not writing code, he's thinking about it or listening to a podcast about it.

Related Posts

How to solve the error assets file project.assets.json not found in Visual Studio

This post tells you how to solve the error assets file project.assets.json not found in Visual Studi…

Read Post

Code to help you debug an umbraco issue on a remote site

This post gives you some razor code to help you see the values of the IPublishedContent item's prope…

Read Post

How to fix the 403 error on preview in Umbraco after upgrading

This post shows you how to fix the 403 error on preview after you have upgraded it.

Read Post

How to restrict Content Apps by user groups in Umbraco

In this post I give you some code so you can restrict the Content Apps on your Umbraco site by user…

Read Post