角度ルートプロバイダに問題があります。 app.jsルートの設定では:AngularJS Routeproviderを使用しているときにASP.NET mvcアクションにリクエストできません
fmApp.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider){
$locationProvider.html5Mode(true);
$routeProvider.when('/', {
templateUrl: 'staticViews/home.html,
controller: 'fmController'
}).otherwise({ redirectTo: '/' })
})
、私のweb.configファイルで、私はindex.htmlをするすべての要求をリダイレクトするURLを書き換える:index.htmlをで
</system.webServer>
<rewrite>
<rules>
<rule name="Rewrite Url to layout.html">
<match url=".*\.html|css/|img/|js/|data/|lib/|templates/|favicon.ico" negate="true" />
<action type="Rewrite" url="layout.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
私は形をしましたそれが提出したとき、私はそれが$ HTTP
$scope.submit = function(){
$http({
method:'post',
url: '/api/test',
data: JSON.stringify(
angular.copy($scope.data)
)
})
}
私の問題は、私は、API /テスト/に要求したとき、それは、サーバsの呼び出しではありませんを使用して、サーバー側のアクションに依頼したいですide(api-controllerとtest-action)はlayout.htmlを呼び出します(web.configに書き直すため)。暗闇の中でだけでショット
コンソールエラーが発生しましたか? –
暗闇の中でちょうど撃たれましたが、あなたのAPIが書き換え否定に含まれていないように見えます。おそらく "。* \ .html | api/| css/| img/| js/| data/| lib/| templates/| favicon.ico"おそらく? – Dillon
@Dillon Wow !!それは完全に働く。大いに感謝する! – vantrung1408