[英]Serve canned offline web content using the Web Browser control
I'm developing a C# replacement for a legacy VB app for my company. 我正在为公司的旧版VB应用程序开发C#替代品。 The front end is basically a Web Browser control inside of a Windows form, serving offline content which is sometimes altered to include the user's data.
前端基本上是Windows窗体内部的Web浏览器控件,用于提供脱机内容,有时会对其进行更改以包括用户数据。 Because there are 100 or more web files in the legacy app, we are going to reuse the web UI from the old application with a new C# wrapper around it, modifying them as needed.
由于旧版应用程序中有100个或更多的Web文件,因此我们将在旧应用程序中使用新的C#包装器重用旧应用程序的Web UI,并根据需要对其进行修改。
My questions are about how to store and deliver the web content. 我的问题是关于如何存储和交付Web内容的。
Some background: 一些背景:
I would probably avoid using a temporary location for the web content it just seems a little crude. 我可能会避免使用一个临时位置作为Web内容,这似乎有些粗糙。 If there is no internal linking between your html pages and all the css/js is embedded in one file it may be easier to just use the WebBrowser.DocumentText property.
如果您的html页面之间没有内部链接,并且所有css / js都嵌入到一个文件中,则仅使用WebBrowser.DocumentText属性可能会更容易。
Another option I have successfully used as a lightweight embedded web server is logv-http , it has a pretty easy to configure syntax. 我已经成功用作轻量级嵌入式Web服务器的另一个选项是logv-http ,它具有易于配置的语法。 If you want to configure against anything other than localhost it does require administrator privileges but it sounds like everything will be local.
如果要针对本地主机以外的其他任何配置进行配置,则它确实需要管理员权限,但听起来一切都将是本地的。
var server = new Server("localhost", 13337);
server.Get("http://localhost:13337" ,(req, res) => res.Write("Hello World!"));
server.Start();
I think the string replaces aren't necessarily bad depends how many there are and how complicated they are trying to be, but for simple find replace it shouldn't be too hard to manage. 我认为字符串替换不一定坏,取决于有多少个字符串以及它们要变得多么复杂,但是对于简单的find替换来说,它应该不太难管理。 If there are lots of replaces wrapping them into a RegEx should help performance.
如果有很多替换项,将它们包装到RegEx中将有助于提高性能。
Storing the web content as embedded resources is probably how I would go that way you can read them out at run-time do you pre-processing and then return either via the the web server method or direct into the DocumentText. 将Web内容存储为嵌入式资源可能是我的处理方式,您可以在运行时将它们读出来,然后进行预处理,然后通过Web服务器方法返回或直接返回到DocumentText中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.