2012-01-27 27 views
6

調試ASP.NET MVC源代碼時發現「MVC-ControllerTypeCache.xml」文件被使用。 但我不能理解這個文件的使用。我的意思是這個文件存儲在哪裏? asp.net MVC如何使用這個文件? 請幫忙。MVC中的MVC-ControllerTypeCache.xml

回答

6

該文件用於緩存控制器類型以避免昂貴的反射查找。它是動態生成的並存儲在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> 

還有這是用來緩存區MVC-AreaRegistrationTypeCache.xml

+0

感謝您的答案Darin.I試圖查看此文件夾內,但我無法找到此文件。 – 2012-01-27 10:49:49

+3

@NirajChoubey,你在Release模式下運行你的應用程序嗎?你在web.config中設置了 2012-01-27 10:51:36