What is the best way to use a Json file as an endpoint?

Forums .NETWhat is the best way to use a Json file as an endpoint?
Staff asked 11 months ago

I’m currently working on a .Net application that integrates with Optimizely CRM. I’d like to access a JSON file similar to

http://www.xyz.com/files/test.json

However, I am able to obtain information from local sources, such as

https://localhost:55236/files/test.json

However, when I try to deploy in the test environment, I receive the following problem.

404

https://www.xyz.com/files/test.json unable to locate

Any assistance would be greatly appreciated.

Answers (1)

Add Answer
Staff answered 2 months ago

Make sure that your iis or iisexpress can send JSON files. Setting the following property in web-config is a common way to accomplish this.

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

 

Thank you

John Price replied 2 months ago

Subscribe

Select Categories