可能です。grunt-contrib-watch ( https://github.com/gruntjs/grunt-contrib-watch )を使用して、ASP.NET アプリでライブ リロードを取得しました。ほんの数分でした。
この記事をガイドとして使用しました:
http://www.aliirz.com/javascript/2013/12/25/Live-Reload-with-Grunt/ .
これは、ASP.NET アプリのフォルダーでコマンド プロンプトを使用して行います。
1. grunt-contrib-watch をインストールする
まだ package.json ファイルがなく、依存関係を 1 つに保存したい場合:
npm init
次に、Grunt と grunt-contrib-watch をプロジェクトに追加します。
npm install --save-dev grunt grunt-contrib-watch
2. Grunt を設定する
次にGruntfile.js
同じフォルダに を作成します。これが私のものです:
'use strict';
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.initConfig({
watch: {
views: {
files: [
'Views/**/*.cshtml',
'Scripts/**/*.js',
'Content/**/*.css',
'Content/images/**/*',
'bin/**/*.dll'
],
options: {
livereload: true,
}
}
}
});
}
3. ライブ リロード サーバーを実行する
ASP.NET アプリと一緒に live-reload サーバーを実行します。
grunt watch
4. ASP.NET にスニペットを追加する
最後に、ASP.NET アプリで有効にするには、 live-reload スニペットをレイアウトやビューに追加するだけです。
<script src="http://localhost:35729/livereload.js"></script>