0

I've developed a software based on ASP.NET MVC and want to protect my View's Razor content. For that I created a resource file and put them there then used VirtualPathProvider for handling .cshtml request.

problem : views using @Html.Partial and no request send to GetFile method in VirtualPathProvider class.

any solution ?

Mironline
  • 2,755
  • 7
  • 35
  • 61
  • No solution but just curious, why you need to protect `.cshtml` ? – cuongle Sep 01 '15 at 10:48
  • 1
    @CuongLe , the final project is going to run on customer's machine and view's source will be available with Notepad! – Mironline Sep 01 '15 at 10:52
  • I know it's not a direct answer to your question, but if you want to deter casual viewers/make views non-updatable - maybe view precompilation would be easier path? see here for discussion: http://stackoverflow.com/a/5515293/1123692 – wmz Sep 01 '15 at 11:26
  • why not have a project that calls your hidden project as a portable area. this way all your important files are in a dll. and called from the project that has nothing. – pool pro Sep 01 '15 at 16:22
  • @RichBailo , I'm actually doing that. I put my razor contents to external `dll` and load them in project , the problem is `VirtualPathProvider` can not understand `@Html.Partial` ! – Mironline Sep 01 '15 at 16:28
  • place the whole project in as Portable area, much easier. you can not share views between projects but you will have to write a custom virtual path provider which could be quite a lot of work. For example you may take a look at the following article which illustrates a custom provider which allows embedding Razor views into separate assemblies and reusing them across multiple MVC applications. http://www.chrisvandesteeg.nl/2010/11/22/embedding-pre-compiled-razor-views-in-your-dll/ but if the whole project is portable area you can just route to the area on run. – pool pro Sep 01 '15 at 16:35

0 Answers0