Live reload with Asp.Net 5

16,010

Solution 1

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...
}

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...
}

Solution 2

context => Mats made a new extension which refreshes automatically after SAVE button. Grag the VS extension from visual studio gallery.

Save your VS changes and the browser is reloaded.

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

Share:
16,010
roeland
Author by

roeland

Updated on June 07, 2022

Comments

  • roeland
    roeland almost 2 years

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

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

  • roeland
    roeland over 8 years
    That works. Would be even better if that was triggered on save.
  • Muhammad Rehan Saeed
    Muhammad Rehan Saeed over 8 years
    That's a good idea. Go ahead and suggest it as an improvement in the ASP.NET GitHub Tooling project.
  • roeland
    roeland over 8 years
    It is also slower than a normal refresh. Not sure why.
  • Muhammad Rehan Saeed
    Muhammad Rehan Saeed over 8 years
    It's using Signal-R to send a message to the browser using Web Sockets to update itself, so there is a slight overhead on the page. The cool thing is, you can open multiple browsers and watch them all refresh at the same time.
  • Muhammad Rehan Saeed
    Muhammad Rehan Saeed over 8 years
    I added a +1 to the issue.
  • priyamtheone
    priyamtheone almost 2 years
    Please specify where shall I write the above Configure method. And my project doesn't have a project.json file. What should I do in that case?