.cshtml更改后,为什么刷新后页面没有更新 [英] Why does page not update after refresh when .cshtml changes

查看:615
本文介绍了.cshtml更改后,为什么刷新后页面没有更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试Blazor,但我不明白为什么刷新浏览器页面后更改component时它不会更新? client是否应该像angular那样更新自身?

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 client update itself similar to how angular does?

它仅在我重新启动blazor服务器时刷新.

It only refreshes when i restart the blazor server.

Index.cshtml

@page "/"

<h1>Hello, world!</h1>

如果我将<h1>内的文本更改为Hello people,则保存项目并刷新页面(如在Blazor教程中建议的那样),我不应该看到Hello people吗?

If i change lets say the text inside the <h1> to Hello people , i save the project and i refresh the page ( as i am advised in the Blazor tutorial) shouldn't i see Hello people ?

推荐答案

在Asp.net Core 3.0之后,使用Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation程序包启用运行时编译. 要启用运行时编译,应用程序必须:

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

安装Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation NuGet软件包.

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

更新项目的Startup .ConfigureServices方法包括对AddRazorRuntimeCompilation的调用:

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

services
    .AddControllersWithViews()
    .AddRazorRuntimeCompilation();

services.AddMvc().AddRazorRuntimeCompilation();  

这篇关于.cshtml更改后,为什么刷新后页面没有更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆