Can I host my console application in IIS? - c#

I've read in some articles that we can create a console application in .NET & we can host that in IIS which makes our console application as web application. Is it a rumour or can we actually do that?
Also, please provide a working example or procedural steps for that, if we could do that?
Thanks

Console application cannot be run as web application in IIS by itself unless you have a web application calling your console application to trigger on it. of course your console application path must be accessible.
Configured framework, run time at ease.

Related

Is there any way to call a desktop application that is installed on a server from a web site?

I have a site written in ASP.NET Core and used ASP boilerplate. Also, I'll have a desktop application which will be installed at the same server. I need to know if it's possible to run this app from my site using it's GUI. Because after running it, I need to save some data from this app. I tried on my local System.Diagnostics.Process and it calls the GUI but I don't know if it is possible in the server.

Always running web service

I've just created a simple asp.NET web service application with a WebMethod that passes the current server time and a Windows form application to run alongside this as a client.
As it stands, for the client app to be able to interact with the server app, the web service application needs to be running (runs in a web browser). If the browser is then closed, the client app cannot talk to the web service app.
Ideally, I would need this web service to always be running in the background on my server at all times (not just when a web browser is opened) and start when the server is booted up.
What would be the best way to achieve this? I have minnimal experience with asp.NET so is there a way to configure the web service to be a background service? Do I need to create a seperate Windows service application that uses asp.NET web services?
Any help appreciated, thanks.
Yes, by default, Visual Studio stops debugging your web application when you close the browser used for debugging... But you shouldn't run your application from Visual Studio. You deploy web applications to IIS. Then they'll start when the machine starts, and they don't need a browser to keep running.

Start up a web-service in a windows-based application

I have a quite old web-service (asmx) that run well on IIS. Now there is a need of start this up in a windows-based application e.g. a console application (or perhaps in a windows service)
Is there any way of hosting the current ASMX project in a console application without modifying this? Unfortunatelly we cannot convert this in a WCF.
I appreciate any help on this.

Run desktop app via WEB app

I have desktop application that can be installed on the users computer with "setup" msi file like any other application.
I'm developing web application and I need somehow to integrate the desktop application with the web application. Web application is developed using PHP (desktop application is developed using C#), and when clicking on one button on the web application, the desktop application needs to be launched.
Is there a way of doing this? I was thinking about a few scenarios:
-Maybe if possible to install the app directly on the server and to launch it from there?
-Maybe to be required the user to have the app installed on his computer and to call the app from there?
If possible I would prefer to not use the second approach because it's better if the third party to not be involved - it will be more user friendly if the application is launched directly. But any help will be appreciated because at this point I'm not sure if that is possible to be done at all.
You can install app at server an run it with exec() or "`" operator - but to control gui of app you need to use some like autoit ant etc.
If you ultimately decide to require your users to have the client application installed and expect majority of the users to be on Windows, you could register your application to handle specific scheme and parse its command line when started. More on this here:
http://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx
You'd register a custom scheme and then intercept in in the application's command line arguments. The whole URL will be passed as an argument, e.g.:
myapp://parameter1,parameter2
The browser will mostly ask whether or not the user trusts the application to handle this scheme with an option to remember this setting.
If you don't have access to the source code of the client application, you can develop a middleware, some sort of a launcher that handles the URL and then runs the client application after maybe modifying some configuration files based on the URL or otherwise controlling the third-party application to do as you with.
As for solution #1, I don't think C# matters if your application can run on Mono, so you should be able to just run it from PHP. However, this probably won't work on web hosting and you will have to get a VPS for that.
There are very good (security) reasons why it is hard to launch client-side processes from web browsers.
Do you have access to the source code of the C# app? If so, you could consider modifying it to take advantage of Microsoft ClickOnce deployment.
Some references:
http://msdn.microsoft.com/en-us/library/t71a733d.aspx
http://msdn.microsoft.com/en-us/library/t71a733d(v=vs.80).aspx
http://msdn.microsoft.com/en-us/library/6ae39a7c.aspx
http://www.codemag.com/Article/0902031
Here's an old article on deploying WinForms applications via ClickOnce with Visual Studio 2005: http://msdn.microsoft.com/en-us/library/ms953320.aspx
It can possibly be done with IIS but it can be cumbersome setting it up to run as the current user, especially since it would probably also need to run elevated for an app that needs to attach to the current user's desktop.
Easiest is to install a Windows LAMP distro (like WAMP: http://www.wampserver.com/en/) and then run the httpd.exe directly from an elevated (Admin) command prompt; do not run apache as a service!
Once you do this performing and exec("command"); call in php will bring up a desktop app as if it was invoked from an admin command prompt. Obviously you need to set up the apache server to be accessible from outside the local system, etc.

Creating a Web Server container to emulate an IIS server

Okay, I'm a very green developer (co-op student) so I'll try my best to make sense. Currently I have a web application (call it "Updater") that is an aspx and runs through IIS. My boss has asked my to look into creating a program (exe or command line) that can run the app through created encapsulated web server that can act like IIS. This is so that I can run the exe during an installer procedure on a client's machine so that the updater can configure the client's program.
So Far I've looked into sources upon sources on how to create a self hosted web server to handle a web app and I've managed to do the following:
-Create a command line server hosted at a given port #######.
-Use a StreamReader to read an html file
-Use HttpResponseMessage to set the Content to this html page.
Obviously this is very rudimentary, but I couldn't understand how to switch the app over to the server I created rather than the IIS.
Any help ont he matter would be appreciated, like I said I'm still quite new.
You can use OWIN to self host from within a console application.
Look for 'Self-Host OWIN in a Console Application' in the following link:
http://www.asp.net/aspnet/overview/owin-and-katana/getting-started-with-owin-and-katana
You need to start you self host server with the address your app is trying to contact. If your IIS is running with the default settings it should be http://localhost:80. Before you start the self host server you need to shut down your IIS website that is running on port 80. Two applications can not listen on the same port at the same time.
What you ask is a redistributable web server for ASP.NET. So, you might find interesting the UltiDev Web Server, formerly known as Cassini web server.
From their website:
UltiDev Web Server Pro (UWS) is an advanced, redistributable web server for Windows that can be use as a regular web server to host web sites and ASP.NET applications, or packaged with your ASP.NET web application and installed on your customers' systems along with your web app or site.

Categories