How to access a JSON file as an endpoint?
Asked Answered
T

2

2

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

Trelu answered 21/3, 2022 at 15:7 Comment(0)
S
4

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>
Sappington answered 21/3, 2022 at 16:18 Comment(0)
B
0

You will have to create a folder named .well-known inside of a wwwroot folder of your web application. After this copy assetlikns.json file in the .well-known folder.

also check if you have json as MIME Types

Open the properties for the IIS server in IIS Manager and click MIME Types. if you don't have .json then click "add" and enter ".json" for the extension and "application/json" for the MIME type.

Burning answered 21/3, 2022 at 15:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.