C# .NET 的迷你 Web 服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/854993/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mini Web Server for .NET
提问by Icemanind
I wrote a VB.NET windows service and I'd like to know if there is some library or something that will provide me with a very simple mini web server. If my service is running, I'd just like to be able to type, in my browser:
我写了一个 VB.NET Windows 服务,我想知道是否有一些库或其他东西可以为我提供一个非常简单的迷你 Web 服务器。如果我的服务正在运行,我只想能够在我的浏览器中输入:
And have a status page popup. It will only be one single page and very simple html. Anyone know an easy way to do this before I attempt it on my own and over-engineer? lol
并有一个状态页面弹出。它只会是一个页面和非常简单的 html。在我自己和过度设计之前,有人知道一种简单的方法吗?哈哈
采纳答案by Icemanind
I actually found a pretty good library of what I was looking for at:
我实际上找到了一个很好的图书馆,里面有我正在寻找的东西:
http://www.codeproject.com/cs/internet/minihttpd.asp
http://www.codeproject.com/cs/internet/minihttpd.asp
If anyone else needs a small mini web site, check out that link. I tried it and liked it.
如果其他人需要一个小型迷你网站,请查看该链接。我试过了,很喜欢。
回答by Peter Lillevold
You should look into Windows Communication Foundation. The framework lets you host your own HTTP endpoint, on which you can serve whatever you want. Here is a sample over at MSDN.
您应该查看 Windows Communication Foundation。该框架允许您托管自己的 HTTP 端点,您可以在该端点上提供任何您想要的服务。这是MSDN 上的一个示例。
回答by jean
Look into the System.Net.HttpListener class. You can specify what port to listen to, and it's up and running pretty quickly.
查看 System.Net.HttpListener 类。您可以指定要侦听的端口,并且它的启动和运行速度非常快。
回答by MatteKarla
if you're using .NET 2.0 you can use System.Net.HttpListener
to create your own web server that takes advantage of the HTTP.SYS
component which is available from WindowsXP SP2 and Windows 2003 Server.
如果您使用的是 .NET 2.0,您可以使用它System.Net.HttpListener
来创建您自己的 Web 服务器,该服务器利用了HTTP.SYS
WindowsXP SP2 和 Windows 2003 Server 中提供的组件。
There's a article about hosting Web Services without using IIS using http.sys at http://msdn.microsoft.com/sv-se/magazine/cc163879(en-us).aspx
在http://msdn.microsoft.com/sv-se/magazine/cc163879(en-us).aspx上有一篇关于使用 http.sys 在不使用 IIS 的情况下托管 Web 服务的文章
回答by ChrisW
Maybe the Cassini server from Microsoft(or, a variant of Cassini from UltiDev), which is implemented by the same technology as used when you debug ASP.NET or a Web Service from within Visual Studio without IIS.
也许是来自 Microsoft 的 Cassini 服务器(或来自 UltiDev 的 Cassini 的变体),它是通过与在不使用 IIS 的情况下从 Visual Studio 中调试 ASP.NET 或 Web 服务时使用的相同技术实现的。
回答by Marc Vitalis
Try WebDev.WebServer.exe. You can past parameter with it such us port and directory.
尝试 WebDev.WebServer.exe。您可以使用它传递参数,例如我们的端口和目录。
回答by Chris S
A couple more suggestions:
还有一些建议:
- NancyFX(look for self host)
- Kayax
- WebServiceHost(used in conjunction with a WCF service)
- NancyFX(寻找自己的主机)
- 皮艇
- WebServiceHost(与 WCF 服务结合使用)