2016-10-16 8 views
0

AngularJSとC#(API用)を使用してASP.NET Core SPAを作成していますが、ページの更新に関して少し問題があります。ブラウザのページのリロードが機能しない

たとえば、2つのリンクを持つホームページがあります。これらのリンクは次のとおりです。 - ホーム(にリダイレクト:/ホーム) - クライアント(にリダイレクト:/クライアント)

の問題は、私は/クライアントルート上だと私は私のページ(F5)を更新すると、あります再読み込み後、私はページをリロードする前と同じビューを持っているはずです。

私のコードがあります:

app.js

var app = null; 

(function() { 
'use strict'; 

appConfig.$inject = ['$routeProvider', '$locationProvider']; 

app = angular.module('app', [ 
    'ngRoute', 
    'ngResource' 
]); 

app.config(appConfig); 

function appConfig($routeProvider, $locationProvider) { 

    // Define the routes 
    $routeProvider 
     .when('/', { 
      templateUrl: '/views/home.html', 
      controller: 'homeController', 
      title: 'Home' 
     }) 
     .when('/clients', { 
      templateUrl: '/views/clients.html', 
      controller: 'clientsController', 
      title: 'Clients' 
     }) 
     .when('/clients/add', { 
      templateUrl: '/views/addClient.html', 
      controller: 'addClientController', 
      title: 'Add new client' 
     }) 
     .when('/404', { 
      templateUrl: '/views/404.html', 
      title: '404 Not found' 
     }) 
     .otherwise({ 
      redirectTo: '/404' 
     }); 

    $locationProvider.html5Mode(true); 
} 

app.run(['$rootScope', '$route', function ($rootScope, $route) { 
    $rootScope.$on('$routeChangeSuccess', function() { 
     document.title = 'Blume - ' + $route.current.title; 
    }); 
}]); 

})(); 

clientController.js

(function() { 
    'use strict'; 

    angular 
     .module('app') 
     .controller('clientsController', clientsController); 

    clientsController.$inject = ['$location', '$scope', '$resource', 'clientService']; 

    function clientsController($location, $scope, $resource, clientService) { 
     $scope.clients = clientService.query(); 
    } 

})(); 

clientService.js

(function() { 
    'use strict'; 

    angular 
     .module('app') 
     .factory('clientService', clientService); 

    clientService.$inject = ['$resource']; 

    function clientService($resource) { 
     return $resource('/api/client/:id'); 
    } 

})(); 

web.configファイル

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    <rewrite> 
     <rules> 
     <!--Redirect selected traffic to index--> 
     <rule name="Index Rule" stopProcessing="true"> 
      <match url=".*" /> 
      <conditions logicalGrouping="MatchAll"> 
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
      <add input="{REQUEST_URI}" matchType="Pattern" pattern="^/api/" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="/index.html" /> 
     </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
</configuration> 
+0

によって実行すべきですか? – charlietfl

+0

投稿を編集してweb.configファイルを追加しました。私はチュートリアルに続き、web.configをコピー/ペーストしました。多分私のエラーはそこからです:/ – Eastrall

+0

また、 "以前と同じように見えるはずのもの"を明確にしていません。*具体的に、または実際に何が起きているのか – charlietfl

答えて

0

残念ながら、これは今のところ修正がありません。 Googleでいくつかの調査をした後、私はIIS上のURL書き換えがちょっと壊れていることを伝えるGitHubの問題を発見しました。

https://github.com/aspnet/IISIntegration/issues/192#issuecomment-226012161

良い事は解決された問題であり、この機能は次の.NETのコア(1.1)のリリースで利用できるようになります。それはあなたが角html5Modeを説明するために、 `web.config`を設定したの秋2016

https://github.com/aspnet/Home/wiki/Roadmap

関連する問題