[英]I have an iframe in my Blazor server app razor page in that an external URL is defined. How can I force to refresh (reload) this url using a button?
I have a Blazor server app.我有一个 Blazor 服务器应用程序。 In one of the razor pages there is shown an external URL (...index.php) in an iframe.
在其中一个剃须刀页面中,iframe 中显示了一个外部 URL (...index.php)。 I have some buttons that are writing some information into a exchange txt file.
我有一些按钮将一些信息写入交换 txt 文件。 After pressing each button the URL is not changing.
按下每个按钮后,URL 不会改变。 I just have to recall the URL, so that the called index.php shall read the new data in the exchange file.
我只需要调用 URL,以便被调用的 index.php 将读取交换文件中的新数据。 How can I force to refresh or reload the URL in my iframe?
如何强制刷新或重新加载 iframe 中的 URL? My Code is:
我的代码是:
@page "/explorer"
@using System.Diagnostics
@using System.IO;
@inject AuthenticationStateProvider _authenticationStateProvider
@using Microsoft.AspNetCore.Http
@inject IHttpContextAccessor httpContextAccessor
<html>
<body>
<button class="btn btn-primary" @onclick="@(() => { @Drive_Letter="C"; File_Explorer();})">C:\</button>
<button class="btn btn-primary" @onclick="@(() => { @Drive_Letter="D"; File_Explorer();})">D:\</button>
<button class="btn btn-primary" @onclick="@(() => { @Drive_Letter="E"; File_Explorer();})">E:\</button>
<button class="btn btn-primary" @onclick="@(() => { @Drive_Letter="F"; File_Explorer();})">F:\</button>
<iframe name="web" src=@URL_Explorer width="1500px"
height="800px" frameBorder="0">
</iframe>
@code{
public static string CurrentUserName { get; set; }
public static string CurrentUserName_trimmed { get; set; }
public string user_path_total;
public static string Drive_Letter;
public string URL_Explorer { get; set; }="";
public void File_Explorer()
{
using (StreamWriter writer = new StreamWriter(exchange_file, append: false))
{
writer.Write("\\\\" + Connect2.MAE_IP_Win + "\\" + Drive_Letter + "$");
writer.Close();
}
URL_Explorer = "https://server:8092/index.php" ;
}
}
更改网址后您尝试使用 StateHasChanged() 吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.