我在Blazor Server应用程序剃须刀页面中有一个iframe,该页面定义了外部URL。如何使用按钮强制刷新此URL(重新加载)?
我有一个Blazor Server应用程序。在其中一个剃须刀页面中,在iframe中显示了一个外部URL(... index.php)。我有一些按钮将一些信息写入Exchange TXT文件。 按下每个按钮后,URL不会更改。我只需要回忆起URL,以便称为index.php应读取Exchange文件中的新数据。我如何强制刷新或重新加载我的iframe中的URL?我的代码是:
@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" ;
}
}
I have a Blazor server app. In one of the razor pages there is shown an external URL (...index.php) in an iframe. I have some buttons that are writing some information into a exchange txt file.
After pressing each button the URL is not changing. I just have to recall the URL, so that the called index.php shall read the new data in the exchange file. How can I force to refresh or reload the URL in my iframe? 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 + "quot;);
writer.Close();
}
URL_Explorer = "https://server:8092/index.php" ;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更改URL后,您尝试使用stateHaschanged()?
You try with StateHasChanged() after change the url?