Using the same code in different Mvc solutions

I am using asp.net mvc 3 and .net framework 4.0 with c #

Let's say I have a NivoSlider html code (slider). 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 various MVC solutions. It will become a plugin somehow.

I cannot do this in part because I need to move all the css, js and imges files to a new solution. I looked at the "mvc areas", but it does not make my js and css files (in fact, using "Areas" is not an ideal way, as you know) ... I was looking for some plugin-based architectures, which are easy to implement. I have a limited time.

So how can I solve this problem?

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

+4
source share
5 answers

You can create a private Nuget and create a small installation for it. This way you can install, update and remove 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 and which files you want to extract.

+15
source

I use a shaving generator in a commercial project and functional, but not perfect.

Other features that I reviewed are Add files as a link (see Answer to Nameless)

Also override ViewEngine Can I specify a custom location for searching and viewing? in ASP.NET MVC?

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

+1
source

As stated above, Razor views can be embedded into the assembly as a compiled class (using the Razor generator). Static resources like .html, .js, .png can be placed in the assembly as an embedded resource and served by the application through VirtualPathProvider (custom or use an existing one, for example https://github.com/mcintyre321/EmbeddedResourceVirtualPathProvider )

+1
source

You can include these files in your Web API project and maintain them for each solution. Each solution must include logic for using these files through the web interface.

0
source

Compile your asp.net mvc Razor into a separate dll

I wanted to be able to embed Razor compiled views in the dll. This would make it easy to distribute asp.net mvc modules that have built-in default views, but allow you to place files in your views folder to override these default views.

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

0
source

Source: https://habr.com/ru/post/1493868/


All Articles