我正在开发一个与Optimizely CMS结合的.NET应用程序。
我想访问一个JSON文件,如:www.abc.com/.well-known/assetlinks.json
我可以在本地访问,如:https://localhost:44300/.well-known/assetlinks.json
但当我尝试部署到测试环境时,我会得到以下错误:
www.abc.com/.assominous/assetlinks.json
404未找到
确保允许iis或iisexpress发送JSON文件。这通常可以通过在web配置中设置以下属性来完成
<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>
您必须在web应用程序的wwwroot文件夹中创建一个名为.known的文件夹。在此之后,将assetlikns.json文件复制到.aknown文件夹中。
还要检查是否有json作为MIME类型
在IIS管理器中打开IIS服务器的属性,然后单击MIME类型。如果您没有.json,那么单击";添加";和输入";。json";对于扩展和";application/json";用于MIME类型。