gpt4 book ai didi

In the Blazor WASM template project, FetchData.FetchDataAsync() works even when the host app is turned off(在Blazor WASM模板项目中,FetchData.FetchDataAsync()即使在主机应用程序关闭时也可以工作)

转载 作者:bug小助手 更新时间:2023-10-25 22:11:00 25 4
gpt4 key购买 nike



After creating and launching the template project of Blazor Webassembly(7.0) in VS 2022, letting the Blazor app start in the browser, and then turning off the Blazor host server by closing the terminal, I navigated to FetchData and found the titled code still works without any problem until refreshing the browser.

在VS 2022中创建并启动Blazor WebAssembly(7.0)的模板项目,让Blazor应用程序在浏览器中启动,然后通过关闭终端关闭Blazor主机服务器后,我导航到FetchData,发现标题代码仍然可以正常工作,直到刷新浏览器。


Its code is as below:

其代码如下:


protected async Task FetchDataAsync()
{
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
}

It is getting the data from the host server thru Http so I expected it to fail.

它通过http从主机服务器获取数据,所以我预计它会失败。


Why is that possible?

为什么这是可能的?


I set Kestrel.

我给凯斯特尔下了套。


更多回答

browser cached it?

浏览器缓存了吗?

@MisterMagoo I didn't know how a browser cache works but deleted application repository in the browser and found it works as I expected.(exception thrown). can you explain in details on how to handle it? eg. configuring not to cache fetched data in the project.

@MisterMagoo我不知道浏览器缓存是如何工作的,但删除了浏览器中的应用程序存储库,发现它的工作方式与我预期的一样。(抛出异常)。你能详细解释一下如何处理吗?例如。配置为不在项目中缓存提取的数据。

sample-data/weather.json is a static file which can be cached. There's no API running on the server.

Sample-Data/weather.json是一个可以缓存的静态文件。服务器上没有正在运行的API。

优秀答案推荐
更多回答

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com