Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Light weight HTTP Server library in .NET

Tags:

c#

.net

http

I'm looking for a small and fast library implementing an HTTP server in .NET

My general requirements are:

  • Supports multiple simultaneous connections
  • Only needs to support static content (no server side processing)
  • HTTP only, HTTPS not needed
  • Preferably be able to serve a page from an in memory source. I want to integrate it into another app to be able to make changing data available via a browser, but I don't want to have to write it to a file on disk first. For example, just pass it a C# string to use as the current page content.
  • Preferably open source so I can modify it if needed
  • Definitely needs to be free... it's for a personal project with no budget other than my own time. I also want to be able to release the final product that would use this library freely (even if that means complying to the particular OSS license of that library.

Edit: To clarify some more, what I need can be REALLY simple. I need to be able to serve essentially 2 documents, which I would like to be served directly from memory. And that's it. Yes, I could write my own, but I wanted to make sure I wasn't doing something that was already available.

like image 277
Adam Haile Avatar asked Nov 07 '08 19:11

Adam Haile


People also ask

Is .NET a web server?

ASP.NET is an open-source, server-side web-application framework designed for web development to produce dynamic web pages. It was developed by Microsoft to allow programmers to build dynamic web sites, applications and services.

What web server does ASP.NET use?

IIS is the most commonly used web server for ASP.NET applications in production environments; it's most likely the web server software being used by your web host provider to serve your ASP.NET application.

Is ASP.NET a web server?

ASP.NET is a mature, server-sideweb development framework from Microsoft. Developers use ASP.NET to create dynamic websites, web apps, and web-based services. After decades of development, the framework persists today as ASP.NET Core.


2 Answers

Use Cassini.

Free, Open Source.

It would take trivial hacking to serve from memory.

like image 128
FlySwat Avatar answered Nov 08 '22 06:11

FlySwat


Well, how complicated of a HTTP server do you need? .NET 2.0 has the HttpListener Class which you can use to roll your own basic library. Since this is for a personal project and you are willing to invest the time, it would also make for a good learning experience as you you would get to learn how to work with the class. Additionally, according to the MSDN documentation, it has an asynchronous mode that gives each request its own thread.

Getting a basic HTTP server with the class up and running isn't too difficult either, you should be able to get it done in only a couple hundred lines of code.

like image 32
rjzii Avatar answered Nov 08 '22 06:11

rjzii