Asp.net

使用 Asp.Net 5 實時重新載入

  • February 21, 2016

在 Asp.Net 5 中,開發速度更快,因為它在保存時編譯。但我仍然需要手動刷新瀏覽器。

Visual Studio 中是否有實時重新載入選項,或者我應該為此使用 gulp 外掛?

您可以啟用 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...
}

引用自:https://stackoverflow.com/questions/33034169