Home > Blockchain >  in VS2019 when I change cshtml code I have to run application again. Is there any option in asp.net
in VS2019 when I change cshtml code I have to run application again. Is there any option in asp.net

Time:11-16

whenever I only change cshtml.cs code in my asp.net core web application, all the time I've to run application again. So, is there any helpful details to solve this problem please tell.

I checked the VS2019 settings and all but couldn't solve.

CodePudding user response:

You can use Browser Link feature to achieve it.

Install these two packages into your project:

Microsoft.VisualStudio.Web.BrowserLink


Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation

Update the project’s Startup.ConfigureServices method to include a call to AddRazorRuntimeCompilation.

public void ConfigureServices(IServiceCollection services)
{
    services.AddRazorPages().AddRazorRuntimeCompilation();
}

Call UseBrowserLink in the Startup.Configure method:

if (env.IsDevelopment())
   {
       app.UseDeveloperExceptionPage();
       app.UseBrowserLink();
   }

Enable Browser Link

enter image description here

Every time after you change your code in cshtml.cs, you can just click this Flame icon and refresh the browser, The new code will apply.

enter image description here

  • Related