I'm using asp.net mvc 3 and .net framework 4.0 with C#

Let's say I have NivoSlider( a slider ) html code. Also it has js, css and image files.

I want to use the NivoSlider cshtml code and js/css/images as "a project" and I want to add it to different MVC solutions. It will become a plugin some-how.

I can't make it a partialview, because I have to move all the css, js and imges files into new solution. I looked at "mvc areas" but it's not rendering my js and css files ( as a matter of fact; using "Areas" is not a perfect way as you know )... I looked up some plugin based architectures, but none-of-them are easy to implement. I have limited time.

So how can I solve this problem ?

EDIT: I can use this http://razorgenerator.codeplex.com/ - But I'm looking for another solutions if you came up with an idea...

有帮助吗?

解决方案

You could create a private Nuget and create a small installation for it. That way you can install, update, and uninstall directly from the package.

You can even make a localized package that you copy between computers. Nuget has a very easy way to specify where you want to extract files to, and what files you want to extract.

其他提示

I'm using razor generator in a commercial project and it's functional but not ideal.

Other possibilities I considered are Add files as link (see Nameless One's answer)

Also overriding the ViewEngine Can I specify a custom location to "search for views" in ASP.NET MVC?

Or even symbolic links (shortcut links to folders in windows) https://superuser.com/questions/234422/does-windows7-support-symbolic-links-folder-shortcuts

As recommended above, Razor views can be embedded into assembly as compiled class (by using Razor Generator). Static resources as .html, .js, .png can be located in the assemble as embedded resource and served by application via VirtualPathProvider (custom or use existing one like https://github.com/mcintyre321/EmbeddedResourceVirtualPathProvider)

Compile your asp.net mvc Razor views into a seperate dll

I wanted to be able to embed compiled Razor views in a dll. This would allow for easy distribution of asp.net mvc ‘modules’ that have their default views embedded, but allowing you to place files in your ‘views’ folder to override those default views.

http://www.chrisvandesteeg.nl/2010/11/22/embedding-pre-compiled-razor-views-in-your-dll/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top