使用 Asp.Net 5 实时重新加载 [英] Live reload with Asp.Net 5

查看:18
本文介绍了使用 Asp.Net 5 实时重新加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Asp.Net 5 中,开发速度更快,因为它在保存时编译.但是我还是得手动刷新浏览器.

In Asp.Net 5 the development is faster because it compiles on save. But I still have to refresh the browser manually.

Visual Studio 中是否有实时重新加载选项,或者我应该为此使用 gulp 插件?

Is there a live reload option in Visual Studio, or should I use a gulp plugin for that?

推荐答案

您可以启用 BrowserLink 并在编辑代码时按 Ctrl+Alt+Enter 使浏览器自动刷新.或者,您可以点击 Visual Studio 工具栏中的浏览器链接刷新按钮.

You can enable BrowserLink and while editing your code hit Ctrl+Alt+Enter to cause the browsers to refresh automatically. Alternatively you can hit the browser link refresh button in the Visual Studio ToolBar.

public void Configure(IApplicationBuilder application)
{
    // Only enable browser link if IHostingEnvironment says it's 
    // running in Development.
    if (this.hostingEnvironment.IsDevelopment())
    {
        // Allow updates to your files in Visual Studio to be shown in 
        // the browser. You can use the Refresh 
        // browser link button in the Visual Studio toolbar or Ctrl+Alt+Enter
        // to refresh the browser.

        application.UseBrowserLink();
    }
    // Omitted...
}

您还需要在 project.json 中添加 Browser Link NuGet 包:

You also need to add the Browser Link NuGet package in your project.json:

"dependencies": {
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta7",
    // Omitted...
}

这篇关于使用 Asp.Net 5 实时重新加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆