I'm using ASP.NET 5 (vNext) with MVC, is there any solution on publishing all the views into an separate dll?
Asked
Active
Viewed 3,780 times
5
-
There is usually no need to do so, as it becomes pain to customize it (in case you ship it as part of a 3rd party library for some CMS or so). May I ask why you need it? If your only concern is performance, you can enable razor view compilation as mentioned in this post http://stackoverflow.com/questions/33518206/does-mvc6-support-precompiled-views. – Tseng Mar 01 '16 at 14:15
-
security is my concern, if i have a dll i can obfuscate it. I know that i'll lose performance but security is mush needed. – Ehsan Zargar Ershadi Mar 01 '16 at 18:27
-
Odd requirements. What kind of stuff do you put into your views, that you have security concerns? View should just display the data you already prepared and other than that just contains the html. Sounds overly paranoid to trying obfuscate them. Imho views should be public so views of 3rd party library can be customized in the applications they are used on. If its not a plugin/extension/package for public consuming then there is also no real need to obfuscate it – Tseng Mar 01 '16 at 20:39
-
If your concern is, that the calls to the non-view related code is visible, well, use viewmodels. don't obfuscate the viewmodels, but obfuscate your domain layer (models, services, repositories). View won't be affected by it as it consumes the viewmodel and not the models – Tseng Mar 01 '16 at 20:41
-
You are right, but view are using dependency injection to access some part of services that are coming from repository, and this can be the point of weakness in security, I want to prevent the server admin from injecting any code from view point. – Ehsan Zargar Ershadi Mar 02 '16 at 01:03
1 Answers
0
The site below contains instructions for compiling Razor views in MVC 3. I am not sure if the technique will work for vNext.
This is a useful mechanism for creating shared view elements across web sites.
http://www.chrisvandesteeg.nl/2010/11/22/embedding-pre-compiled-razor-views-in-your-dll/
This may also help: Sharing Razor views across projects
This gitHub project is the ultimate version of the preceding: https://github.com/RazorGenerator/RazorGenerator