How to open Console App from MVC web application

kailash solanki 1 Reputation point
2021-02-19T07:15:21.283+00:00

I have deployed MVC application in IIS, and from this MVC application i want to open console app. so that is not possible due to IIS security .

Now i have create one package installer add added console application exe in Application and decalared protocol of package and i have installed that package on my pc and i am able to see the protocol.

now in MVC controller i am writing code to open protocol

             Uri uri = new Uri("myprotocol:");
             var psi = new ProcessStartInfo();
            psi.UseShellExecute = true;
            psi.FileName = uri.ToString();
            Process.Start(psi);

but i am getting below exception -

System.Exception: A specified logon session does not exist. It may already have been terminated
---> System.ComponentModel.Win32Exception: A specified logon session does not exist. It may already have been terminated

is there any solution on this.

if i replace console app to UWP that is working fine for me but i want Winform OR console App but in both not able to open from IIS.

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,410 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SurferOnWww 2,411 Reputation points
    2021-02-19T07:57:19.713+00:00

    i want Winform OR console App but in both not able to open from IIS.

    It is NOT possible because IIS runs without a user interface. You can check if the Environment.UserInteractive Property in your web application.

    Environment.UserInteractive Property
    https://learn.microsoft.com/en-us/dotnet/api/system.environment.userinteractive

    1 person found this answer helpful.