3

Somewhat related to this question, I'm looking for a web server for Windows that I can include/embed into my WinForms application:

  • Must be able to host, run and serve ASP.NET Web API.
  • Must be able to serve static files (like e.g. images).
  • Must be shippable with my application's setup.
  • Must be installable/deployable without administrative privileges.
  • Must be usable without having the user to run my application (or the setup of the application) with administrative privileges).

Maybe I can go with Cassini web server but I'm looking for more professional/up-to-date alternatives, including commercial ones.

The web server itself can be pretty limited:

  • Only need to be used from within the application itself.
  • Only need to work locally.
  • Needs no authentication.

My question:

Can someone recommend me solutions that meet the above criteria?

0

After some weeks of searching and trying (and discarding) various solutions, I found the Kestrel web server integrated into .NET Core the most suitable thing (see also my similar question on Stack Overflow).

There is a fantastic example over at Rick Strahl's weblog (GitHub repository with the whole example) on how to use Kestrel together with ASP.NET Core Web API and even MVC.

Since .NET Core can ship completely without dependencies (see below), I could go with a scenario similar to something like this:

  1. Include a complete Kestrel project into my setup executable.
  2. Include my "normal" WinForms application into my setup executable.

Then, I have something completely stand-alone with no external web server dependencies.

You can also use the Kestrel web server in a "normal" .NET Framework project, e.g. .NET 4.6.1. Simply add the Microsoft.AspNetCore.Server.KestrelNuGet package as a reference.


Ship .NET Core Framework

Just as a reference for others and my future self, here is how to ship the whole .NET Core Framework binaries with your application:

  1. Edit "project.json".
  2. Remove the "type": "platform" from the "Microsoft.NETCore.App" dependencies.
  3. Add "runtimes": { "win10-x64": {} } (or others if required).
  4. Publish.

See the bottom section "All right, but they told that this is similar to java! Can I publish a really self-contained asp.net application, which also ships the framework?" on the "project.json settings in asp.net core" blog article for more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.