.netasp.net-mvcepiserver

How to access a JSON file as an endpoint?


I am working on a .NET application combined with Optimizely CMS.

I would like to access a JSON file like: www.abc.com/.well-known/assetlinks.json

I can access locally like: https://localhost:44300/.well-known/assetlinks.json

But when I try to deploy to the test environment, I get this error:

www.abc.com/.well-known/assetlinks.json

404 not found


Solution

  • Ensure your iis or iisexpress are allowed to send JSON-files. This can typically be done by setting the following property in web-config

    <mimeMap fileExtension=".json" mimeType="application/json" />
    

    A sample of the element would be

    <system.webServer>
        <staticContent>
          <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00"/>
          <!--cacheControlCustom="public"-->
          <remove fileExtension=".woff"/>
          <remove fileExtension=".woff2"/>
          <remove fileExtension=".otf"/>
          <remove fileExtension=".ttf"/>
          <remove fileExtension=".eot"/>
          <mimeMap fileExtension=".woff" mimeType="application/font-woff"/>
          <remove fileExtension=".woff2"/>
          <mimeMap fileExtension=".woff2" mimeType="font/woff2"/>
          <mimeMap fileExtension=".otf" mimeType="application/x-font-opentype"/>
          <mimeMap fileExtension=".ttf" mimeType="application/x-font-ttf"/>
          <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject"/>
          <mimeMap fileExtension=".json" mimeType="application/json" />
        </staticContent>
    <system.webServer>