/ / JSON-Datei nach dem Hochladen auf AZURE [geschlossen] nicht gelesen - asp.net, json, api, azure, web

JSON-Datei nach dem Hochladen auf AZURE [closed] nicht gelesen - asp.net, json, api, azure, web

Ich habe einen Asp erstellt.net-API-Anwendung, die die Daten aus einer JSON-Datei liest und in einer Tabelle anzeigt. Wenn ich es von Visual Studio aus ausführen lese, werden die Daten erfolgreich gelesen und angezeigt. Nachdem ich sie jedoch in Azure hochgeladen habe, ist die Tabelle leer.

Ich habe es im "jsondata" -Ordner gespeichert und der Aufruf erfolgt folgendermaßen

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

Kopf:

<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>

Karosserie:

<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>

Skript zum Lesen der Json-Datei mit eckig:

<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>

Antworten:

1 für die Antwort № 1

Um statische .json-Dateien von einem Azure App Service aus bereitzustellen, müssen Sie die folgende MimeMap zu Ihrer web.config Datei:

<?xml version="1.0"?>

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

Referenz: So stellen Sie statische .json-Dateien von einer Windows Azure-Website bereit