Unable to add a new MIME type to an Azure Web App web server

George Parrish 1 Reputation point
2021-11-29T17:30:43.953+00:00

I am hosting some static files on my Azure Web App web server.

I am able to access most of these static files when request them through my web browser.

However any files which have a file extension of ".data" are causing the web server to return a 404 error.

I have modified the existing web.config file ( which I found in the root of the web server) adding a new MIME type to this file, for files with extension ".data".

After doing this I found that the web server still responds with a 404 when I request these files through my web browser.

Please advice how I successfully add a new MIME type to an Azure Web App web server?

My web.config file looks like this

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>

    <staticContent>
        <remove fileExtension=".data" />
        <mimeMap fileExtension=".data" mimeType="application/octet-stream" />
    </staticContent>

    <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
    </handlers>

    <aspNetCore processPath="dotnet" arguments=".\MyWebApp.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" hostingModel="inprocess" />

</system.webServer>

</configuration>

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,826 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Oscar Maqueda 536 Reputation points Microsoft Employee
    2021-11-29T18:11:20.407+00:00

    If the <staticContent> element already exists you just need to add the <mimeMap> element to this section for the type you want to add, try to delete the remove paragraph

    0 comments No comments

  2. George Parrish 1 Reputation point
    2021-11-30T08:13:53.947+00:00

    The <staticContent> section didnt already exist, I'm not sure why you think that it already existed? I had to add it, as shown in the code snippet.

    0 comments No comments

  3. George Parrish 1 Reputation point
    2021-11-30T08:18:43.113+00:00

    To clarify, I added this to the <system.webServer> section of the web.config file ( as shown above ), and the web server still reports 404s for files with extension ".data"

    <staticContent>
             <remove fileExtension=".data" />
             <mimeMap fileExtension=".data" mimeType="application/octet-stream" />
         </staticContent>
    
    0 comments No comments