C# NET HTTP.SYS web server

4.1k views Asked by At

I just need to create an extremely basic web server that will basically allow me to go to http://1.2.3.4:8080 and browse a list of files in C:\web or something.

I found this http://mikehadlow.blogspot.com/2006/07/playing-with-httpsys.html which looks perfect but I ran into a couple of questions.

1) When I replace the IP with * or + like the documentation says, I get access denied errors in system.dll. When I use localhost or my local IP it works fine. Why is this? I would like to potentially be able to bind it to a specific IP address on machines that have more than one.

2) I am probably missing something, but how do you specify the core directory where the files are that it is serving with this code?

4

There are 4 answers

1
TomTom On

re 1: because you dont have permissions to register this url. Use "http add urlacl2 to register permissions for your user (as admin) to make the binding. Example: http add urlacl url=http://+:8080/ user=DOMAIN\UserName

Re 2: You dont. THat is pretty much your code. Http.sys does not read from a file system - it is a driver. Your application must read the files and answer the request.

0
TWA On

This might be a little overkill for what you want, but check out the aspNETserve web server project.

It is open source, so at the very least you can browse the code to get some ideas.

2
Nathan Anderson On

I know this does not help you with your code problems, but why re-invent the wheel! I think you should look at using IIS Express, as I think it could meet your needs nicely:

http://learn.iis.net/page.aspx/868/iis-express-overview/

IIS Express is a standalone executable that will provide all the functionality you need. It will also run on Windows XP and above.

0
Motomotes On

Here's a Simple and Secure C# Webserver, offering Digest authentication without the need for Active Directory. Digest Auth is broken, but it is not practical to crack with passwords over 18 characters, anyway one can see how to make a webserver using C# and .NET HTTP.SYS which was the point of this question.

https://git.motes.camp/web/index.php?p=DigestAuthWebServer.NET-HTTPSYS.git&a=summary

clone url: https://git.motes.camp/DigestAuthWebServer.NET-HTTPSYS.git