Library tutorials & articles
Create your own Web Server using C#
Summary
This article explains how to write a simple web server application using C#. Though it can be developed in any .net supported language, I chose C# for this example. The code is compiled using beta2. Microsoft (R) Visual C# Compiler Version 7.00.9254 [CLR version v1.0.2914]. It can be used with Beta1 with some minor modification. This application can co-exists with IIS or any web server, the key is to choose any free port. I assume that the user has some basic understanding of .net and C# or VB.Net. This Web server just returns html formatted files and also supports images. It does not supports any kind of scripting. I have developed a console-based application for simplicity.
Related articles
Related discussion
-
Buy cheap Xanax overnight. Cheap Xanax. Overnight delivery of Xanax in US no prescription needed. Cheapest Xanax.
by asleymar (0 replies)
-
Buy Soma online without a prescription. Soma drug no prescription. How to get Soma prescription. Soma cod accepted.
by asleymar (0 replies)
-
Cheap online order Fioricet. Cheap discount Fioricet. Offshore Fioricet online. How to buy Fioricet online without a prescription.
by asleymar (0 replies)
-
Buy Ambien no visa without prescription. Not expensive Ambien prescriptions. Ambien no rx. Cod delivery Ambien.
by asleymar (0 replies)
-
Tramadol without doctor rx. Buy Tramadol over the counter cod overnight. Cheap Tramadol cod delivery. Buy Tramadol from mexico online.
by asleymar (0 replies)
Related podcasts
-
Object-Oriented Programming in Ruby
In this episode, I talk with Scott Bellware about object-oriented programming in Ruby, and Ruby's object model. This is taken from a private conversation, and the audio quality suffers at times. Much thanks to Scott for allowing this to be released.This episode of the Alt.NET Podcast is bro...
header:
content-encoding=gzip
Hehe, I moved permanently to C# only a month or 2 after
.
creating this thread
I now have trouble reading VB code. Array access looks like
function calls, etc...
i find c# more comprehensible then VB.
for a C# programmer is more difficult for read VB code...
hello,
i need to write a service Windows of the base a the same server.
I am traiyng to use this code in the WinService(c# .NET), but a error was occured:
the system has stopped listen etc...
I think the problem is in the
while(true){...}
and i think this need make sleep the thread for sometime....
How about the POST type,
I noticed that when client send a POST type,
only the http headers appear and nothing follows, even there are attachments.
I still understood all the code.
gotta love .NET!
It's amazing how little code it takes to write a functioning web server these days. Consider the old MFC samples for comparison.
You might consolidate your text file parsing code. The whole semicolon searching system is pretty generic. Or go with XML like you said.
You should support the HEAD verb b/c dropping the connection when it's not a GET request will anger many browsers in terms of caching.
You shouldn't read the whole file into memory using a string concatenation loop. The socket class probably has a method to efficiently transmit an entire file. If it doesn't, you should have your loop read a little and write a little, otherwise those multi-megabyte flash and BMP and MP3 files will start to kill your server.
This thread is for discussions of Create your own Web Server using C#.