嵌入整个目录结构

发布于 2024-10-07 14:06:18 字数 536 浏览 0 评论 0原文

我有一个很大的目录结构,其中包含相互依赖的 JavaScript、图像等。我想将其全部封装到一个 DLL 中,这样我只需引用一件事,而不必在项目中拥有所有这些文件的多个副本。

因为这些文件相互依赖,所以我想我可以创建一个 IHttpModule 来注册一个路由来接受 URL,例如 /MyEmbeddedDir/subdir/file.js。 MyEmbeddedDir 中的任何内容都将由执行正确映射的自定义 IHttpHandler 进行处理。然后,每个 Web 应用程序都需要引用 DLL 并将模块和处理程序添加到 web.config。这看起来合理吗?

另外,是否有比将构建操作设置为嵌入资源 并将 [assemble: WebResource(...)] 添加到每个文件(有几十个!)?谢谢!

编辑:如果我不使用 WebResource.axd 那么我不需要添加 [ assembly: WebResource(...)]

I have a large directory structure with JavaScript, images, etc. that depend on each other. I would like to encapsulate it all into a DLL so I only have to reference one thing and not have multiple copies of all these files across projects.

Because the files depend on each other, I'm thinking I can create an IHttpModule that registers a route to accept URLs such as /MyEmbeddedDir/subdir/file.js. Anything in MyEmbeddedDir would then be handled by a custom IHttpHandler that does the correct mapping. Each web application would then need to reference the DLL and add the module and handler to web.config. Does this seem reasonable?

Also, is there an easier way to embed/reference the files than to set the build action to embedded resource and add [assembly: WebResource(...)] to each file (there are dozens!)? Thanks!

Edit: If I'm not using WebResource.axd then I shouldn't need to add [assembly: WebResource(...)]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

等风也等你 2024-10-14 14:06:18

是的,拥有一个容器是管理大量文件的好方法(不,SQLite 在这里没有帮助!;)。

我们有一个名为 SolFS 的产品,它是一个虚拟文件系统,可让您将数据保存在自定义存储(资源DLL是选项之一)并提供用于访问文件的文件API。我们甚至为 IE 实现了异步可插拔协议(在客户端,但任务与您的非常相似)。 SolFS 包含一个管理器应用程序,可让您轻松创建容器文件并将文件导入容器。

Yes, having a single container is a great way to manage large number of files (and no, SQLite won't help here! ;).

We have a product, named SolFS, which is a virtual file system, that lets you keep your data in custom storage (resource DLL is one of the options) and provides file API for accessing the files. We even implemented asynchronous pluggable protocol for IE (on the client side, but the task is very similar to yours). SolFS includes a manager application that lets you easily create container files and import files into container.

我最终选择了 IHTTPModule (注册路由)和 IHTTPHandler (获取嵌入资源)。该路由可在 web.config 中配置,以防与现有内容冲突。

I ended up going with the IHTTPModule (register route) and IHTTPHandler (obtain embedded resource). The route is configurable in web.config in case it conflicts with existing content.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文