SVG still doesn't show up after adding mime type

I am trying to display an svg image.

When I display the svg image with the below code, it is not displayed.

<img src="/img/logo.svg" alt="Logo">

      

I also tried this syntax, but then it loads instead of being displayed.

<embed type="image/svg+xml" src="/img/logo.svg" />

      

I have already set the mime type to image / svg + xml in web.config.

<staticContent>
    <remove fileExtension=".svg" />
    <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
    <remove fileExtension=".svgz" />
    <mimeMap fileExtension=".svgz" mimeType="image/svg+xml" />
</staticContent>

      

The file type seems to be application / octet-stream, although I defined it in image / svg + xml. I am running an ASP.NET site with IIS 7.

+3


source to share


3 answers


I recently ran into this problem and my web.config syntax for the mime type is slightly different from yours.

It:



<staticContent>
    <mimeMap fileExtension="svg" mimeType="image/svg+xml" />
</staticContent>

      

- everything I added and that fixed the problem. Hope this helps!

0


source


If you have access to the .htaccess file (in the root directory) add this line of code:



AddType image/svg+xml .svg .svgz

      

0


source


Add the following to your web config:

    <system.webServer>
    <staticContent>
      <remove fileExtension=".svg" />
      <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
    </staticContent>
        <handlers>
            <add name="SVG Handler" path="*.svg" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Unspecified" />
        </handlers>
  </system.webServer>

      

0


source







All Articles