使用Gulp浏览器同步的Cshtml文件

时间:2016-03-11 22:38:32

标签: asp.net razor gulp browser-sync

如何让gulp浏览器同步与MVC ASP.net一起使用?它可以与.html文件一起使用,但是当我使用.cshtml文件时它会下载一个空白文件。

gulp.task("browser-sync", function () {
    browserSync({
        server: {
            baseDir: "./",
            proxy: "localhost",
            index: "Areas/Music/Views/Songs/Index.cshtml"
        }
    });
});

gulp.task("watch", function () {
    gulp.watch(["js/*.js", "Content/*.css", "Areas/**/*.cshtml"], ["scripts", "css", "html"]);
});

gulp.task("default", ["scripts", "css", "html", "browser-sync", "watch"]);

1 个答案:

答案 0 :(得分:-1)

试试这个:

homeTemplate, err = template.ParseFiles(
    "views/layout/base.gohtml",
    "views/layout/menu.html",
    "views/layout/footer.gohtml",
    "views/home.gohtml")
if err != nil {
    panic(err)
}

contactTemplate, err = template.ParseFiles(
    "views/layout/base.gohtml",
    "views/layout/menu.html",
    "views/layout/footer.gohtml",
    "views/contact.gohtml")
if err != nil {
    panic(err)
}