本文介绍了如何在APP Service中识别JSON格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在构建在应用程序服务中发布的网络应用程序(aspcore 3.0).此问题是无法识别地雷类型(json).如何解决?谢谢

We’re building a web app (aspcore 3.0) published in app service.This problem is that the mine type (json) is not recognized. How to fix it ?Thank you

推荐答案

听起来您正在Windows上使用Azure App Service部署ASP.NET Core 3.0应用程序,但是Azure WebApp上的IIS无法设置响应标头 Content-Type .

It sounds like you were using Azure App Service on Windows to deploy your ASP.NET Core 3.0 application, but IIS on Azure WebApp can not set the response header Content-Type for JSON.

原因是Azure WebApp上的IIS默认不支持静态JSON文件.要对其进行修复,您需要更改 web.config 文件以添加该功能,如下所示.

The reason is IIS on Azure WebApp default does not support static JSON file. To fix it, you need to change the web.config file to add the feature, as below.

<?xml version="1.0"?>
<configuration>
    <system.webServer>
        <staticContent>
            <mimeMap fileExtension=".json" mimeType="application/json" />
     </staticContent>
    </system.webServer>
</configuration>

作为参考,还有另一个SO线程遇到了与您类似的问题,我已经回答了,请参阅它.

As reference, there is the other SO thread Getting "404 not found" on doing a GET on local file in Azure web app got the similar issue as yours and I answered it, please refer to it.

这篇关于如何在APP Service中识别JSON格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 09:12