1.ASP.NET MVC3源碼下載 Codeplex http://aspnet.codeplex.com/releases
3.添加ASP.NET MVC3源碼中的下面幾個project到調試用的solution中
其實剛開始做的時候是先做的第4步,然后通過vs錯誤提示找到下面這幾個project的 System.Web.Helpers System.Web.Mvc System.Web.Razor System.Web.WebPages System.Web.WebPages.Deployment System.Web.WebPages.Razor
4.修改TestMVC3 project的引用項為源碼中的project System.Web.Helpers System.Web.Mvc System.Web.WebPages
按照最初的設想到這里應該是已經可以了,但是一運行,不行啊,繼續。 5.修改TestMVC3的web.config
根目錄web.config
<system.web> 下 <compilation>節
<compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null" /> <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> </assemblies> </compilation>
<runtime>節
<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="null" /> <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime>
剛開始以為到這里就可以了,運行發現會拋出assembly不一致的異常。
通過異常信息看到name為system.web.webPages.razor的section中配置的還是GAC中的assembly。
直接在project中查找system.web.webPages.razor,找到了Views目錄中的web.config(昏頭了怎么把它給拋在腦后了?)。
找到了就好辦多了,看了看都是下載的源碼中的project,直接把PublicKeyToken都改成null就ok了
F5,OK,熟悉的畫面出來了吧
還有異常?是的,The controller for path '/favicon.ico' was not found or does not implement IController.
這個都知道怎么解決吧,或者說可以忽略了。
1:加上favicon.ico
2:在Global.asax文件的路由器配置中加上
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });




