MVC中的MVC-ControllerTypeCache.xml

Nir*_*bey 7 asp.net-mvc

在调试ASP.NET MVC源代码时,我发现使用了"MVC-ControllerTypeCache.xml"文件.但我无法理解这个文件的用法.我的意思是这个文件存储在哪里?asp.net MVc如何使用这个文件?请帮忙.

Dar*_*rov 7

该文件用于缓存控制器类型,以避免昂贵的反射查找.它是动态生成并存储在c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\NAMEOFYOURAPP\xxxxx\xxxxxxxx\UserCache\文件夹中的.

它由TypeCacheUtil您可以在ASP.NET MVC源代码中的TypeCacheUtil.cs中找到的内部类处理.

以下是此文件的外观示例:

<?xml version="1.0" encoding="utf-8"?>
<!--This file is automatically generated. Please do not modify the contents of this file.-->
<typeCache lastModified="04/01/2012 16:35:03" mvcVersionId="3cff62e5-ef21-4e58-897f-d0f1eafd3beb">
  <assembly name="Custom.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null">
    <module versionId="0bd9573a-7a89-4eab-b33d-cc92573fc2ba">
      <type>APPNAME.Controllers.BaseController</type>
    </module>
  </assembly>
  <assembly name="APPNAME.BusinessLogic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
    <module versionId="3fb0cce6-10dd-43d3-a44c-00046017b574">
      <type>APPNAME.BusinessLogic.Controllers.AssetsController</type>
      <type>APPNAME.BusinessLogic.Controllers.HomeController</type>
    </module>
  </assembly>
  <assembly name="MvcContrib, Version=2.0.36.0, Culture=neutral, PublicKeyToken=null">
    <module versionId="889dd733-c7a0-4ae6-8f50-934f417174ea">
      <type>MvcContrib.PortableAreas.EmbeddedResourceController</type>
      <type>MvcContrib.SubController</type>
    </module>
  </assembly>
</typeCache>
Run Code Online (Sandbox Code Playgroud)

还有MVC-AreaRegistrationTypeCache.xml用于缓存区域的东西.

  • @NirajChoubey,您是否在发布模式下运行应用程序?你在web.config中设置了`<compilation debug ="false"...`吗?只有在发布模式下运行时才使用此文件. (3认同)