我正在开发一个可以在本地运行但在我将其部署到我们的服务器之后就无法运行的 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 theEXE
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/