Why does page not update after refresh when .cshtml changes

后端 未结 4 964
礼貌的吻别
礼貌的吻别 2020-12-08 10:09

I am trying out Blazor and i do not understand why when changing a component after refreshing the browser page it does not update ? Shouldn\'t the

相关标签:
4条回答
  • 2020-12-08 10:19

    After Asp.net Core 3.0, Runtime compilation is enabled using the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation package. To enable runtime compilation, apps must:

    Install the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation NuGet package.

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

    services
        .AddControllersWithViews()
        .AddRazorRuntimeCompilation();
    

    or

    services.AddMvc().AddRazorRuntimeCompilation();  
    
    0 讨论(0)
  • 2020-12-08 10:24

    I guess you are running the app with the debugger connected? this prevents the recompilation. You need to:

    Press Ctrl-F5 to run the app without the debugger. Running with the debugger (F5) isn't supported at this time.

    https://github.com/dotnet/aspnetcore/issues/5456

    0 讨论(0)
  • 2020-12-08 10:31

    If you go into Tools > Options > Keyboard and search in the "Show commands containing" search box search for "BrowserLink". Find the option that says "OtherContextMenus.BrowserLink.RefreshLinkedBrowsers" by default this is set to CTRL+Alt+Enter. Click "Remove" and then select the "Press Shortcut Keys" input and press Ctrl+S. Next (just to the left of the input) change Use new shortcut in "Global" to be "Text Editor". Click "Ok" until the window has closed. Now Visual Studio shares CTRL+S with both Saving files and Refreshing linked browsers.

    (This will only work if your text editor .cshtml, .css, .js, etc. files in the edit window are the active selections) WARNING: if you don't set it to something other than global then it will override the shortcut for Save and you won't be able to save your files.

    0 讨论(0)
  • 2020-12-08 10:35

    You should add or enable runtime compilation in razor pages,

    Install-Package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation -Version 3.1.6

    After installing set the startup file as ,

     services.AddMvc().AddRazorRuntimeCompilation();
    
    0 讨论(0)
提交回复
热议问题