anglejsを使用して、新しいasp.netコアWebアプリケーション(完全な.netフレームワークを使用)を作成しています。 1.5.8。
私たちはアプリを使い始めているので、非常にシンプルなatmです。生徒のデータが入ったテーブルが1ページだけ含まれています。
IIS Expressを使用してアプリケーションを実行すると、アプリケーションが正常に動作し、データが表示され、ブラウザのコンソールにエラーは表示されません。
しかし、ローカルのIISにアプリを公開しても機能しません。角度表示は空ですので、_レイアウトだけが表示されます。
https://docs.asp.net/en/latest/publishing/iis.htmlに記載されている手順を試しましたが、私が言ったように、動作しません。IISにAngularJSを使用してASP.NET CORE Webアプリケーションを公開
Program.Main():
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
site.js(角のもの):
はangular.module('digitalRural', ['ngRoute', 'ngMaterial'])
.config(function ($routeProvider) {
$routeProvider
.when('/', // Students controller
{
controller: 'StudentsController as students',
templateUrl: 'html/students/index.html'
})
.when('/student/edit/:studentId',
{
controller: 'EditStudentController as editStudent',
templateUrl: 'html/students/edit.html'
})
.when('/student/new',
{
controller: 'NewStudentController as newStudent',
templateUrl: 'html/students/new.html'
})
.when('/login/', // Login controller
{
controller: 'LoginController as loginCtrl',
templateUrl: 'html/home/welcome.html'
})
.otherwise({
redirectTo: '/'
});
})
.controller('StudentsController',
function ($http) {
var students = this;
$http.get("/api/students")
.then(function (response) {
students.items = response.data;
});
})
.controller('LoginController',
function ($http) {
var loginCtrl = this;
$http.get("/api/login")
.then(function (response) {
loginCtrl.currentUser = response.data;
});
});
ここでは、画像の
はここで私が使用しているコードですデプロイされたアプリケーション:
とChromeのコンソールでのエラー:
Failed to load resource: the server responded with a status of 404 (Not Found)
angular.js:13920 Error: [$compile:tpload] http://errors.angularjs.org/1.5.8/$compile/tpload?p0=html%2Fstudents%2Findex.html&p1=404&p2=Not%20Found
at Error (native)
at http://localhost/DigitalRural/lib/angular/angular.min.js:6:412
at http://localhost/DigitalRural/lib/angular/angular.min.js:156:511
at http://localhost/DigitalRural/lib/angular/angular.min.js:131:20
at m.$eval (http://localhost/DigitalRural/lib/angular/angular.min.js:145:347)
at m.$digest (http://localhost/DigitalRural/lib/angular/angular.min.js:142:420)
at m.$apply (http://localhost/DigitalRural/lib/angular/angular.min.js:146:113)
at l (http://localhost/DigitalRural/lib/angular/angular.min.js:97:322)
at J (http://localhost/DigitalRural/lib/angular/angular.min.js:102:34)
at XMLHttpRequest.t.onload (http://localhost/DigitalRural/lib/angular/angular.min.js:103:4)
奇妙な何は、すべてのIIS Expressで正常に動作しますが、IISで、私は上記のエラーメッセージを取得することです。
何がありますか?あなたのコンパイルされたバージョンは、「HTML /学生/」または「HTML /ホーム/」でこのテンプレートを持っている場合、あなたのモジュールは、あなたのテンプレート、レビューをロードすることはできませんので
angularjsは必要なテンプレートファイルを見つけることができません。ブラウザのネットワークタブを見てください。多くの404エラーが表示されます。あなたは、私は何かが欠けていた場合、私が判断するのに役立つことができますので、私は、ディレクトリのスクリーンショットが含まれますproject.json – scokmen
チェック。おかげで/ – Set