ASP.NET MVC - Updated Razor Precompilation View Live in Production File

I was wondering if the following is possible:

  • Precompile Razor views with our MVC application by enabling project customization in visual studio.
  • Deploy the production application.
  • Then, at a later stage, update the views by overwriting the existing * .cshtml files during production without reusing the application pool or recompiling the project and redeploying the assembly.
+5
source share
2 answers

Yes you can do it. The viewer recompiles all the files in each directory into a separate DLL into a file like this

C:\Windows\Microsoft.NET\Framework\v4.0.30319\ ASP.NET \micropedi_mvc\d3b5b4cd\eb219373\App_global.asax.ihdiifed.DLL

ILSpy Reflector, , . , DLL.

Note that all that MvcBuildViews` post build, , , .

<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
   <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
</Target>

RazorGenerator. cshtml DLL, , MvcBuildViews. .

, UsePhysicalViewsIfNewer RazorGeneratorMvcStart.cs true, , .


. - , DLL cshtml ,

 <div>This file is compiled to  @this.GetType().Assembly.CodeBase</div> 

, .

+7

, .

cshtml , . .

-1

All Articles