/ / AZUREへのアップロード後にJSONファイルが読み込まれない[終了]-asp.net、json、api、azure、web

JSONファイルは、アップロード後に読み込まれませんAZURE [閉じる] - asp.net、json、api、azure、web

ASPを作成しました。JSONファイルからデータを読み取り、テーブルに表示するnet apiアプリケーション。 Visual Studioから実行すると、データが正常に読み取られて表示されますが、Azureにアップロードした後、テーブルは空です。

「jsondata」フォルダーに保存すると、次のように呼び出しが行われます。

var request = {
method: "get",
url: "../jsondata/data.json",
dataType: "json",
contentType: "application/json"
};

頭:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>

体:

<div ng-app="myApp"
ng-controller="myController">

<table class="table table-bordered table-hover">
<thead>
<tr>
<th>ID</th>
<th>Furniture Piece</th>
<th>Category</th>
<th>Price</th>
</tr>
</thead>

<tbody>
<tr ng-repeat="furniture in list">
<td>{{furniture.ID}}</td>
<td>{{furniture.Name}}</td>
<td>{{furniture.Type}}</td>
<td>{{furniture.Price}}</td>
</tr>
</tbody>

</table>
</div>

角度付きのjsonファイルを読み取るためのスクリプト:

<script>

var app = angular.module("myApp", []);
app.controller("myController",
function ($scope, $http) {

var request = {
method: "get",
url: "../jsondata/data.json",
dataType: "json",
contentType: "application/json"
};

$scope.arrFurniture = new Array;

$http(request)
.success(function (jsonData) {
$scope.arrFurniture = jsonData;
$scope.list = $scope.arrFurniture;
})
.error(function () {

});
});
</script>

回答:

回答№1は1

Azure App Serviceから静的.jsonファイルを提供するには、次のmimeMapを追加する必要があります web.config ファイル:

<?xml version="1.0"?>

<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</configuration>

参照: Windows Azure Webサイトから静的.jsonファイルを提供する方法