ASP .NET On_Load method not executing

牧云@^-^@ 提交于 2019-12-24 07:34:40

问题


I am working on a kludge which is working locally but not after I deploy it to our server.

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.

My Web Page code:

<%@ 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# Code:

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);
    }
}

When I browse to my page on IIS I see the page appear and close after the Timeout but the Application doesn't run. If I copy the EXE path into Windows Explorer the application runs, but it does not from the method. Any help appreciated


回答1:


It sounds like you're trying to launch a UI exe on the client, but what you're actually doing is executing it on the web server. If that's right, then fundamentally what you're trying to do is just ... not going to work. Ignoring the fact that the implementation would have to be completely different, browsers are explicitly designed not to run arbitrary executables from web servers - plus of course it would only work on certain OSes - presumably windows in this case.

A few years ago I might have said "look into ClickOnce for this" - but I have no idea whether that option is still supported or recommended.



来源:https://stackoverflow.com/questions/47397006/asp-net-on-load-method-not-executing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!