简体   繁体   English

我的 Blazor 服务器应用程序剃须刀页面中有一个 iframe,其中定义了外部 URL。 如何使用按钮强制刷新(重新加载)此 url?

[英]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.

相关问题 如何在 Blazor Server 应用程序的 Razor 页面中通过标记代码(单击输入字段时)清空文本输入字段? - How can I empty a text input field via markup code (when I click the Input-field) in my Razor page of my Blazor Server app? 如何加载相同的 Blazor 页面并使用不同的参数访问相同的 url 并将参数显示到 Blazor 中的 UI? - How can I load the same Blazor page hitting same url with different parameters and show the parameter to UI in Blazor? 如何在 Blazor Serv 中执行与 razor 页面输入字段的 onchange 事件相关的 function。 应用程序? (我必须在函数中使用输入值) - How can I perform a function related to a razor page input field's onchange event in Blazor Serv. App? (I have to use the input value in the function) 如何在 Blazor 中创建 Razor 页面列表 - How can I create a List of Razor Page in Blazor 使用Sage Pay iFrame方法,对于客户单击url完成付款,如何生成iFrame URL? - Using Sage Pay iFrame method ,for customer click the url to complete the payment,how can I generate the iFrame URL? 如何刷新ListItem或从URL重新加载它 - How do I refresh a ListItem or reload it from an URL 如何让 Url.Action() 识别在引用的 Razor 类库中定义的区域? - How can I make Url.Action() recognize areas defined in referenced Razor Class Libraries? 如何在 Blazor 应用程序的 Razor 页面中添加多个模型? - How to have multiple models added in Razor page of Blazor app? 如何在 blazor webassembly 应用程序中获取服务器 url? - How to get the server url in blazor webassembly app? 我无法在 blazor 服务器应用程序中的 .razor 页面中使用 C# 类 - I can not use a C# class in a .razor page, in a blazor server application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM