2013-03-15 67 views
0

我試圖安裝MVC3,MVC4和網頁2上的IIS工作,它不斷告訴我,@FileUpload.GetHTML不存在...文件上傳不剃刀網頁2

Server Error in '/' Application.

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 'FileUpload' does not exist in the current context

Source Error:

Line 17:  <body> 
Line 18:  <h1>FileUpload - Single-File Example</h1> 
Line 19:  @FileUpload.GetHtml(     <---- RED LINE 
Line 20:   initialNumberOfFiles:1, 
Line 21:   allowMoreFilesToBeAdded:false, 

我已經盡力複製DLL的手動,以確保它們是正確的版本等

  • System.Web.Helpers.dll
  • System.Web.Razor.dll
  • System.Web.WebPages.dll
  • System.Web.WebPages.Deloyment.dll
  • System.Web.WebPages.Razor.dll

從微軟的例子似乎包括Microsoft.Web。幫手?不能在Razor(v2)中找到任何地方...

是FileUpload不是Razor V2 Helpers的一部分嗎?

回答

2

發現它!最後!缺少NuGet包。

的Microsoft.Web.Helpers不是既不MVC3的一部分,MVC4,剃鬚刀V2,WebMatrix的2

你只需要添加的NuGet打包呼籲: 「的ASP.NET Web助手庫」(爲什麼其所謂的ASP.NET,而不是微軟是有點愚蠢的我,但是這是你需要得到FileUpload.GetHTML幫手assitance一個

我沒有注意它,因爲它的NuGet指出:

This package contains web helpers to easily add functionality to your site such as Captcha validation, Twitter profile and search boxes, Gravatars, Video, Bing search, site analytics or themes.

因此,搞清楚UPLOAD也是這個的一部分,wa我真的不清楚。

以爲我會與同伴分享confusers這:-)

4

@FileUpload.GetHTML不是System.Web.Helpers組件的一部分。這是Microsoft.AspNet.Web.Helpers.Mvc的NuGet,你必須在你的項目安裝的一部分:

Install-Package Microsoft.AspNet.Web.Helpers.Mvc 
+0

我只知道,你沒有回答正確。這個幫手被稱爲「Microsoft.Web.Helpers.dll」沒有MVC。 – BerggreenDK 2013-03-15 14:14:11

+0

但是,儘管我在您的帖子之前找到了答案,但我盡力了。無論如何謝謝。 – BerggreenDK 2013-03-15 15:11:07