Embedding whole directory structure
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 (there are dozens!)? Thanks![assembly: WebResource(...)]
to each file
Edit: If I'm not using WebResource.axd then I shouldn't need to add [assembly: WebResource(..开发者_JAVA技巧.)]
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.
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.
精彩评论