如何访问 JSON 文件作为端点?
How to access a JSON file as an endpoint?
我正在开发结合了 Optimizely CMS 的 .NET 应用程序。
我想访问 JSON 文件,例如:www.abc.com/.well-known/assetlinks.json
我可以像这样在本地访问:https://localhost:44300/.well-known/assetlinks.json
但是当我尝试部署到测试环境时,我得到这个错误:
www.abc.com/.well-known/assetlinks.json
404 not found
您必须在 Web 应用程序的 wwwroot 文件夹中创建一个名为 .well-known 的文件夹。在.well-known文件夹中复制assetlikns.json文件后。
还要检查您是否有 json 作为 MIME 类型
在 IIS 管理器中打开 IIS 服务器的属性,然后单击 MIME 类型。
如果您没有 .json 然后单击“添加”并
输入“.json”作为扩展名,“application/json”作为 MIME 类型。
确保允许您的 iis 或 iisexpress 发送 JSON-files。这通常可以通过在 web-config
中设置以下 属性 来完成
<mimeMap fileExtension=".json" mimeType="application/json" />
元素的样本是
<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>
我正在开发结合了 Optimizely CMS 的 .NET 应用程序。
我想访问 JSON 文件,例如:www.abc.com/.well-known/assetlinks.json
我可以像这样在本地访问:https://localhost:44300/.well-known/assetlinks.json
但是当我尝试部署到测试环境时,我得到这个错误:
www.abc.com/.well-known/assetlinks.json
404 not found
您必须在 Web 应用程序的 wwwroot 文件夹中创建一个名为 .well-known 的文件夹。在.well-known文件夹中复制assetlikns.json文件后。
还要检查您是否有 json 作为 MIME 类型
在 IIS 管理器中打开 IIS 服务器的属性,然后单击 MIME 类型。 如果您没有 .json 然后单击“添加”并 输入“.json”作为扩展名,“application/json”作为 MIME 类型。
确保允许您的 iis 或 iisexpress 发送 JSON-files。这通常可以通过在 web-config
中设置以下 属性 来完成<mimeMap fileExtension=".json" mimeType="application/json" />
元素的样本是
<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>