【问题标题】:Live reload with Asp.Net 5使用 Asp.Net 5 实时重新加载
【发布时间】:2016-01-07 03:51:10
【问题描述】:

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

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

【问题讨论】:

    标签: asp.net visual-studio-2015 asp.net-core asp.net-core-mvc livereload


    【解决方案1】:

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

    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 包:

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

    【讨论】:

    • 那行得通。如果在保存时触发那就更好了。
    • 这是个好主意。继续建议它作为ASP.NET GitHub Tooling 项目的改进。
    • 它也比正常刷新慢。不知道为什么。
    • 它使用 Signal-R 向浏览器发送消息,使用 Web Sockets 进行自我更新,因此页面上有一点开销。很酷的是,您可以同时打开多个浏览器并观看它们全部刷新。
    • 我为这个问题添加了 +1。
    【解决方案2】:

    context => Mats 做了一个新的扩展,在 SAVE 按钮后会自动刷新。从 Visual Studio 库中抓取 VS 扩展。

    保存您的 VS 更改并重新加载浏览器。

    https://visualstudiogallery.msdn.microsoft.com/46eef4d9-045b-4596-bd7f-eee980bb5450

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-14
      • 2021-02-05
      • 1970-01-01
      • 2016-07-07
      相关资源
      最近更新 更多