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(...)]
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.