Tôi Tạo mới dự án ASP.NET MVC 3 RTM và Thay thế tài liệu tham khảo cho sử dụng ASP.NET MVC 3 Source codeLỗi này trong dự án ASP.NET MVC 3 RTM là gì?
nhưng khi tôi chạy dự án một lần nữa, có được ngoại lệ này:
Lỗi[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection. Type A originates from 'System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_1.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'. Type B originates from 'System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\2505c7ee\369315c5\assembly\dl3\f7bae428\d03eeed8_85bbcb01\System.Web.WebPages.Razor.DLL'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Nguồn:
Line 106: internal static RazorWebSectionGroup GetRazorSection(string virtualPath) {
Line 107: // Get the individual sections (we can only use GetSection in medium trust) and then reconstruct the section group
Line 108: return new RazorWebSectionGroup() {
Line 109: Host = (HostSection)WebConfigurationManager.GetSection(HostSection.SectionName, virtualPath),
Line 110: Pages = (RazorPagesSection)WebConfigurationManager.GetSection(RazorPagesSection.SectionName, virtualPath)
Source File: E:\GreenTour\webpages\src\System.Web.WebPages.Razor\WebRazorHostFactory.cs Line: 108
Cảm ơn - nhận xét của bạn "tệp web.config nằm trong thư mục lượt xem" vừa cho tôi một "ah ha!" chốc lát. – DaveHogan
Điều này. Tôi quên rằng có các tệp web.config khác nằm trong thư mục Views (và các thư mục con). –
+1, giải pháp của bạn hoạt động như nét duyên dáng .. :) – dotNETbeginner