javascript - ASP .NET On_Load 方法未执行

标签 javascript c# asp.net pageload

我正在开发一个可以在本地运行但在我将其部署到我们的服务器之后就无法运行的 kludge。

I have a web page which opens, runs an EXE and then closes the web page. Locally this works but after publishing to the server the EXE does not run. I have confirmed that the file path works from the server.

我的网页代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EmailSignature_EXEC.aspx.cs" Inherits="_Default" %>

<html>
<head>
    <title></title>
<script>
function loaded()
{
    window.setTimeout(CloseMe, 500);
}

function CloseMe() 
{
    window.open('', '_self').close();
}
</script>
<script type="text/javascript">
</script>
</head>
<body onLoad="loaded()">
Hello!
    \\\\cmbfs02\\Software\\web\\EmailSignature_WPF\\EmailSignature_WPF.exe
</body>
</html>

C#代码:

using System.Diagnostics;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load()
    {
        var applicationPath = "\\\\cmbfs02\\Software\\web\\EmailSignature_WPF\\EmailSignature_WPF.exe";
        Process.Start(applicationPath);
        this.ClientScript.RegisterClientScriptBlock(this.GetType(), "Close", "window.close()", true);
    }
}

当我在 IIS 上浏览我的页面时,我看到页面出现并在 Timeout 后关闭,但应用程序没有运行。如果我将 EXE 路径复制到 Windows 资源管理器中,应用程序将运行,但它不会从方法中运行。任何帮助表示赞赏

最佳答案

听起来您正试图在客户端 上启动一个 UI exe,但实际上您正在做的是在网络服务器上执行它。如果那是对的,那么从根本上说,您要尝试做的就是……行不通。忽略实现必须完全不同的事实,浏览器被明确设计为不会从网络服务器运行任意可执行文件 - 当然它只能在某些操作系统上运行 - 在这种情况下可能是 Windows。

几年前我可能会说“为此调查 ClickOnce”——但我不知道该选项是否仍受支持或推荐。

关于javascript - ASP .NET On_Load 方法未执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47397006/

相关文章:

javascript - 如果具有相同的 id,如何将数组对象值合并到数组

c# - 使用 C# 中的字典,将某些自定义类属性用作同一类中另一个属性(形成为值)的唯一键

c# - 我应该抛出 Global.asax 的 Application_Error 处理程序中发生的异常吗?

javascript - 通过输入类型 ="file"选择文件并将源文件附加到视频元素

javascript - 我将如何在 javascript 中为此编写解释器?

Javascript:从另一个文件调用 D3 中的函数

c# - 使用函数在天蓝色表存储中使用多个查询参数

c# - 解析 'The specified string is not in the form required for a subject.'

c# - 更新面板和 Anthem 如何在客户端隐藏方法名称

asp.net - 如何 "push"更新 (ASP.NET) 网页表格/网格中的各个单元格?