3

I have an asp.net mvc 3 project that uses Razor. I am able to store the views in a shared library, but I also want to store additional resources like images, stylesheets and javascript files in a shared library. So my question is:

How can I store stylesheets, javascript and images in a shared library?

2
  • What exactly do you m ean by a shared library? Do you mean a folder like the one called Shared in which the views are stored? Commented Dec 1, 2011 at 21:47
  • I mean a Class Library in Visual Studio that I can share between multiple projects. Commented Dec 2, 2011 at 5:03

1 Answer 1

4

If you want to share static resources such as images, stylesheets and javascript files between multiple projects I would recommend you creating a separate web application that will host those resources and which will be accessed by all other applications. A sort of CDN if you will. The benefit of a CDN is that all applications have a single location for those static resources meaning that clients of all applications will have those resources in cache.

If you want to store them in a separate assembly that would mean that each application will have a different copy of them => clients of your applications won't benefit from this caching. You could still do it if you will. Simply embed those resources into the library and then write a controller action that will read them and serve them.

Sign up to request clarification or add additional context in comments.

2 Comments

How do I access an embedded resource from a controller?
@redeeze, you could use the GetManifestResourceStream method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.