简体   繁体   English

在C#中通过局域网托管网页?

[英]Hosting Webpage over Local Area Network in C#?

I have a C# form application that has different functionality. 我有一个具有不同功能的C#表单应用程序。 Additionally I want to add another service to the existing project which is hosting the webpage " CameraCapture.html " page over Local Area Network as a web service in order to be viewed from another client on the Network. 另外,我想向现有项目中添加另一项服务,该项目通过Web托管在局域网上作为Web服务托管“ CameraCapture.html ”页面的网页,以便从网络上的另一个客户端进行查看。

For this purpose I have added one form " frm_cameraServer_monotor " and two Buttons in this form, btn_StartServer and btn_StopServer , which to start serving "CameraCapture.html" and to stop serving it. 为此,我添加了一种形式“ frm_cameraServer_monotor ”和两种形式的按钮btn_StartServerbtn_StopServer ,它们开始提供“ btn_StopServer ”并停止提供它。 My IP Address on LAN is: 10.140.191.200 (static) . 我在LAN上的IP地址是: 10.140.191.200 (static)

I don't want to use any web server like Apache and ISS to be installed and configured. 我不想使用任何Web服务器(如Apache和ISS)进行安装和配置。 Just I want a server service to existing project. 我只是想为现有项目提供服务器服务。

Any one can understand and help me in this topic, really very appreciated Thanks. 在这个主题上任何人都可以理解和帮助我,非常感谢。

I want to start web-service but without web-server 我想启动Web服务但没有Web服务器

If it is just a plain HTML without back-end but not a web-service, then you can create a shared folder and open it as a file from your network. 如果这只是没有后端的纯HTML而不是Web服务,则可以创建一个共享文件夹并从网络中将其作为文件打开。 HTML and front-end JS scripts will work well. HTML和前端JS脚本可以很好地工作。 However, the link will be like: 但是,该链接将类似于:

file:\\COMPUTER-001\Camera\CameraCapture.html

If it is ok for you, then you can easily do this without web-server. 如果您还可以,那么无需Web服务器即可轻松完成此操作。

You surely cannot make it work this way without any HTTP-server: 如果没有任何HTTP服务器,您肯定无法使其工作:

http://COMPUTER-001/CameraCapture.html HTTP://COMPUTER-001/CameraCapture.html

Is it worth it? 这值得么?
Install a simple web-server, you even won't need to configure it if a single HTML file is everything you need. 安装一个简单的Web服务器,如果只需要一个HTML文件,甚至不需要配置它。

If you want to host an asp.net site on your application (winforms/service/wpf/whatever) you can use CassiniDev 如果要在应用程序上托管一个asp.net网站(winforms / service / wpf /其他),则可以使用CassiniDev

Then simply publish your web project to your filesystem and use: 然后只需将您的Web项目发布到文件系统并使用:

        CassiniDev.Server server = new CassiniDev.Server({port number}, {publishedSitePath});
        server.Start();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM