2013-10-01 85 views
0

我試圖按照這些指示Asp.Net MVC 4添加到Asp.Net Web表單4.5的Web應用程序:添加Asp.Net MVC 4到一個Asp.Net Web表單4.5 Web應用程序

http://www.hanselman.com/blog/IntegratingASPNETMVC3IntoExistingUpgradedASPNET4WebFormsApplications.aspx

區別在於本文討論了將Asp.Net MVC 3添加到Asp.Net Webforms 4.0應用程序中。

獲取應用程序建立我還必須添加以下的NuGet包:

  • Microsoft.AspNet.Web.Optimization
  • Microsoft.AspNet.WebApi.WebHost
  • Microsoft.AspNet。網頁

以及這些包所具有的任何依賴關係。 (我認爲這些是asp.net mvc 4模板中的一些新東西所需要的,例如捆綁和Web Api。)

當運行應用程序時,我可以訪問我的webforms default.aspx頁面。但是,試圖訪問MVC路線/首頁/索引時/我得到的死亡以下黃屏:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0103: The name 'BeginContext' does not exist in the current context

Source Error:

Line 50: #line default Line 51: #line hidden Line 52: BeginContext("~/Views/Home/Index.cshtml", 39, 2, true); Line 53: Line 54: WriteLiteral("\r\n");

Source File: c:\Users\deap\AppData\Local\Temp\Temporary ASP.NET Files\root\4e75f435\a63aa726\App_Web_index.cshtml.a8d08dba.m4g9z3sv.0.cs Line: 52

沒有人有任何想法發生了什麼事情,我需要做的就是它運行的是什麼?

回答

0

經過一個良好的夜間睡眠,我決定將我的web.config與我從中複製文件夾的虛擬mvc web應用程序進行比較。

更改以下:

<dependentAssembly> 
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" /> 
</dependentAssembly> 

到:

<dependentAssembly> 
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> 
</dependentAssembly> 

解決我的問題。

相關問題