简体   繁体   English

Blazor开发过程中代码修改后如何刷新页面

[英]How to refresh page in Blazor development process after code changing

For me, a biggest discomfort of Blazor development is absent to simple refreshing page after tiny changing HTML of style in source code.对我来说,Blazor 开发的最大不适在于在源代码中对 HTML 样式进行微小更改后的简单刷新页面。 Since ASP.NET was born this opportunity has been present - we changing something in HTML or in code, than simple click refresh in browser and new page instantly was appear in browser.自从 ASP.NET 诞生以来,这个机会一直存在 - 我们在 HTML 或代码中进行了更改,而不是在浏览器中简单地单击刷新,新页面立即出现在浏览器中。 But in Blazor development even after tiny changing code or HTML we must stop web server then start full compilation sourse code again and after compilation has been ended successfully IIS will be started and Browser will be started. But in Blazor development even after tiny changing code or HTML we must stop web server then start full compilation sourse code again and after compilation has been ended successfully IIS will be started and Browser will be started. And even after that HTML-page will be showing in Browser.甚至在该 HTML 页面将显示在浏览器中之后。 In Classic ASP.NET we was have even more faster development method - Designer of Visual Studio with directly showing any HTML-changing.在经典 ASP.NET 中,我们有更快的开发方法 - Visual Studio 设计器,直接显示任何 HTML 更改。 Current Blazor development process slows down speed of Web-development for millions times.当前的 Blazor 开发过程使 Web 开发速度减慢了数百万倍。 Is this possible to restore convenient ASP.NET workflow of web-development in Blazor at least to the MVC development speed (with simple refresh page in Browser without recompliation and restarting all development components after tiny changing of code or HTML?这是否可以将 Blazor 中 Web 开发的便捷 ASP.NET 工作流程至少恢复到 MVC 开发速度(在浏览器中简单刷新页面,无需重新编译并在代码或 Z4C4AD5FCA2E7A3F74DBB1CED04 微小更改后重新启动所有开发组件?

There is a commercial solution called LiveSharp.net which solves most of your problems.有一个名为 LiveSharp.net 的商业解决方案可以解决您的大部分问题。 They offer a free trial.他们提供免费试用。 I personally use it and it really saves a lot of time, especially when doing CSS / HTML tweaking.我个人使用它,它确实节省了很多时间,尤其是在进行 CSS / HTML 调整时。

In addition, .NET 6 is announced to offer hot reload out of the box.此外,.NET 6 宣布提供开箱即用的热重载。

<script>
    Blazor.defaultReconnectionHandler._reconnectCallback = function (d) {
        document.location.reload();
    }
</script>

Paste it in _Host.cshtml file (or your custom host file) in the body section like this:将其粘贴到正文部分的 _Host.cshtml 文件(或您的自定义主机文件)中,如下所示:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM