Why isn't a compilation needed when updating cshtml files with .net code?

前端 未结 2 1079
离开以前
离开以前 2021-02-14 11:08

I\'m using Asp.net Mvc and I wanted to know why I don\'t need to compile my project when updating .net code in cshtml files? Now if we are talking about html\\css updates then I

2条回答
  •  独厮守ぢ
    2021-02-14 11:40

    Part of the ASP.NET infrastructure is the ASP.NET compiler. It is responsible for compiling declarative resources (*.aspx, *.ascx, *.cshtml etc.) into executable code.

    There is no magic, the runtime decides when to run the compiler (e.g. when the resource has been changed since last run) and then invokes the compiler to create an imperative code out of the declarative code (e.g. an *.aspx is compiled into *.cs). Then it invokes regular language compiler to get a *.dll containing CIL.

    This takes some time for the first time a resource is accessed, it could be handy to precompile all declarative resources ahead of time.

    Overview:

    http://msdn.microsoft.com/en-us/library/vstudio/ms178466(v=vs.100).aspx

    Precompilation:

    http://msdn.microsoft.com/en-us/library/aa983464(v=vs.110).aspx

提交回复
热议问题