Join us this Friday for AI in Action at the Virtual Happy Hour! This free virtual event is open to all—enroll now on Academy and don’t miss out.

 

How to access a Json file as an endpoint ?

Vote:
 

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.

#276801
Mar 21, 2022 14:37
Vote:
 

Have  you checked if the json file is present in the test environment?

#276844
Mar 22, 2022 7:40
Vote:
 

I think the most likely reason is, as Tomas suggests, that the file hasn't been deployed for some reason but, if the file is there and you're still getting a 404, it could be an issue with mime type mappings. If you're on .net 4.x, you can add a mapping for the file type in web.config like this:

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

If you're on .net >= 5, you'll need to add your mapping in your startup class using app.UseStaticFiles.

#276846
Mar 22, 2022 9:57
Rashed - Mar 22, 2022 14:43
thanks. this piece of code really worked well.
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.