Tom Schreck
Tom Schreck

Reputation: 5287

ASP.Net MVC 3 accessing CSS, JS files from separate DLL

I'm following this link, compile razor files into separate dll, and can get it to work except I can't figure out how to access JavaScript, CSS, and Images embedded in the dll.

Has anyone used this approach? It seems very promising. Thanks.

Upvotes: 3

Views: 3643

Answers (2)

mcintyre321
mcintyre321

Reputation: 13306

You can use my EmbeddedResourceVirtualPathProvider which can be installed via Nuget to load all kinds of resources from referenced assemblies, and also can be set to take dependencies on the source files during development so you can update views without needing a recompile.

Upvotes: 1

Darin Dimitrov
Darin Dimitrov

Reputation: 1038820

The technique presented in this article is for embedding razor views into separate assemblies. It doesn't allow you to do so with static resources such as images, js and CSS. For those type of resources you will have to implement a custom solution. For example you could write a controller which, given a resource name, could read it from the assembly (GetManifestResourceStream) and write the stream to the response. Then you could simply generate links to this controller action in your views (Url.Action) and pass the resource name.

Upvotes: 2

Related Questions