Home > Net >  How to access a Json file as an endpoint?
How to access a Json file as an endpoint?

Time:03-22

I am working on a .Net application comnined with Optimizely CRM. i would like to access a json file like

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

but i can able to accress from local like

https://localhost:44300/.well-known/assetlinks.json

but wehen i try to deploy in the test environment i get this error

www.abc.com/.well-known/assetlinks.json 404 not found

Any help would be highly appricited.

CodePudding user response:

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.

CodePudding user response:

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>
  • Related