[ACCEPTED]-Is it possible to create a standalone, C# web service deployed as an EXE or Windows service?-embeddedwebserver

Accepted answer
Score: 15

Yes, it's possible, you may want to have 1 a look at WCF and Self Hosting.

Score: 5

Yes, it is possible (and fairly easy).

Here 3 is a CodeProject article showing how to make a basic HTTP server 2 in C#. This could easily be put in a standalone 1 EXE or service, and used as a web service.

Score: 3

One technology you might want to check out 4 is WCF. WCF can be a bit of a pain to get 3 into but there's a great screencast over 2 at DNRTV by Keith Elder that shows how to 1 get started with WCF in a very simple fashion.


Score: 1

You could take a look at HttpListener in the .Net framework.


Score: 1

I would highly recommend WCF. It would 3 fit very well into a product like you are 2 describing. There are a good number of 1 books available.

Score: 1

Sure, you can do that. Be sure to change 7 the Output Type of the project to Console 6 Application. Then, in your Main function, add 5 a string[] parameter. Off of some switch 4 that you receive on the command line, you 3 can branch to ServiceBase.Run to run as 2 a Windows Service or branch to some other 1 code to run a console application.

Score: 1

This question is somewhat older but since 14 I needed something similar some time ago 13 it felt like this question is still relevant.

I 12 wrote a small Rest-API with NancyFx and 11 OWIN. OWIN is a standard interface between 10 .Net applications and web servers. With 9 OWIN it is possible to create a self-hosted WEB-API. Nancy 8 on the other hand is

a lightweight, low-ceremony, framework 7 for building HTTP based services on .NET 6 ¹

The combination of those two makes it possible 5 to create a self-hosted C# Web service. I 4 am quite sure that there are many more possibilities 3 to create something like this by now but 2 since I used it like this I thought the 1 Information might be useful to someone.

More Related questions