What does the webpages:Version setting do?

2019-01-26 03:16发布

问题:

When creating a new project using the ASP.Net MVC 3 tools it adds the following application setting to the Web.config:

<appSettings>
  <add key="webpages:Version" value="1.0.0.0"/>
</appSettings>

What does it do?

回答1:

This was recently introduced in ASP.NET MVC 3 projects (after installing the ASP.NET MVC 3 Tools Update). I guess it is in preparation for handling upcoming WebPages releases (Razor) in ASP.NET MVC 4 where you will be able to choose the version of the razor view engine with your application. Currently it doesn't do much.



回答2:

From the MSDN Blog,

It determines which version of Razor engine to use when editing razor webpage files.

In VS2013 Preview, we released new Razor V3 runtime and design time Engine to support MVC5 and Razor V3 website’s runtime and design time behavior. Unlike Razor V2 runtime and design time, VS2013 did not GAC these binaries. Instead, the binaries are installed in the project bin folder when corresponding NuGet package is installed, and in “%ProgramFiles (x86)%\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions \Microsoft\Web\Razor\v3.0” to support design time.`

If the key is missing from web.config file such as default Razor V2/V3 website, VS will use bin directory’s razor dll version to determine the design time razor engine dll to load.

Updated 10/9/2013: In VS2013 RC and RTW, VS will open the single webpage file using the highest Razor version on the box if a single webpage file (i.e. cshtml or vbhtml files) is opened without bin directory nor web.config setting.



回答3:

It is being used to distinguish between the second and the third version of Razor engine.