.NET Core Blazor WebAssembly 中的本机错误

Nav*_*r V 1 .net-core webassembly blazor blazor-client-side

我的任务是运行 CLI 命令(在客户端系统中)并在 Web 应用程序上向用户显示输出。[假设,一个基于网络的 cmd.exe ]

基于对 WebAssembly 功能的了解,我使用 .NET CORE Blazor WebAssembly 来完成该任务。但是在客户端中使用System.Diagnostics.ProcessStartInfo会引发运行时错误Native error= Cannot find the specified file

如果我对 WebAssembly 的理解有误,请告诉我。另外,建议我如何完成任务?

Razor 页面中使用的代码:

protected override async Task OnInitializedAsync()
{
    quiz = await Http.GetJsonAsync<List<QuizItem>>("Quiz");

    // My actual code...
    string process = @"C:\Windows\System32\cmd.exe", arguments = "start", workingFolder = ".";
    System.Diagnostics.ProcessStartInfo startinfo = new System.Diagnostics.ProcessStartInfo {
        FileName = process, Arguments = arguments, WorkingDirectory = workingFolder,
        CreateNoWindow = false, UseShellExecute = false,
        RedirectStandardError = true, RedirectStandardOutput = true,
    };
    System.Diagnostics.Process proc = System.Diagnostics.Process.Start (startinfo);
    if (proc == null) throw new Exception ($"Unable to execute '{process}'");
}
Run Code Online (Sandbox Code Playgroud)

控制台日志供参考:

在此输入图像描述

Flo*_*res 5

blazor的权限受到浏览器javascript沙箱的限制,所以你不能做任何你在javascript中也不能做的事情。启动进程就是其中之一。