名称空间'System.Web'中不存在类型或命名空间名称'Http'

时间:2017-01-27 07:47:02

标签: c# asp.net asp.net-mvc

我的Asp.net MVC操作返回一个视图。该操作没有错误,但是在编译阶段视图结束时出现此错误。我不知道这个System.Web.Http.Data.Helpers来自哪里。我从这个动作中添加了一个全新的空MVC视图。它得到了同样的错误。此应用程序使用MVC 5.2.3.0和.NET Framework 4.5.2。有谁知道问题是什么?谢谢。

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: CS0234: The type or namespace name 'Http' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

Source Error:




Line 26:     using System.Web.Optimization;
Line 27:     using System.Web.Routing;
Line 28:     using System.Web.Http.Data.Helpers;
Line 29:     
Line 30:     


Source File: c:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\App_Web_accessrequest.cshtml.f4cc22dc.wyu-er3-.0.cs    Line: 28 



Show Detailed Compiler Output:




C:\Program Files (x86)\IIS Express> "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" /t:library /utf8output /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WinForms\10.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WinForms.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activities.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.DataVisualization\12.0.0.0__89845dcd8080cc91\Microsoft.ReportViewer.DataVisualization.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\17f2d89a\005843ef_e538d201\System.Spatial.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.ApplicationServices\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.ApplicationServices.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\f90554c5\0033c11d_e638d201\Microsoft.Data.Services.Client.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\462aa9eb\00a1c9ec_4a3bd001\AjaxMin.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Web\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.VisualStudio.Web.PageInspector.Loader\v4.0_1.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Web.PageInspector.Loader.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\76c1f975\00d3e643_e638d201\Microsoft.Data.Edm.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\a4d0f7a8\00d9ab6a_b76bd201\Microsoft.WindowsAzure.Storage.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Deployment\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Deployment.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\b3845a67\007c06f2_e72ed201\Microsoft.WindowsAzure.Configuration.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.DynamicData\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.DynamicData.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activation\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activation.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.Services\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SqlServer.Types\12.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.Types.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.Extensions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\f20c5ade\00a06763_c729cf01\itextsharp.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.Common\10.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.Common.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\016d1299\007175d9_0e55d001\EntityFramework.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.WorkflowServices\v4.0_4.0.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\d7846dc9\007175d9_0e55d001\EntityFramework.SqlServer.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\App_global.asax.vinu2f-w.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\d672e3c6\005b0492_f23ad001\System.Web.Helpers.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\2bb4d80c\dbf24d75_18c3cf01\WebGrease.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.DomainServices.Hosting\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.DomainServices.Hosting.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\290cb87c\2f542505_6e78d201\CMT.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\ebdad562\431537fc_a4f7d001\AjaxControlToolkit.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\27d7eeaa\00ec03df_1b19cd01\Elmah.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\da0ee3a6\00e4da9d_b050d201\Microsoft.Azure.KeyVault.Core.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\5481e0d3\004f2fdb_02c6d101\Newtonsoft.Json.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\811e0cf8\490e9572_18c3cf01\System.Web.Optimization.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.ProcessingObjectModel\12.0.0.0__89845dcd8080cc91\Microsoft.ReportViewer.ProcessingObjectModel.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\d2819038\0078360d_e321cf01\Glimpse.Mvc4.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\3c672836\00d2b709_acf3cf01\Glimpse.AspNet.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Web.Infrastructure\v4.0_1.0.0.0__31bf3856ad364e35\Microsoft.Web.Infrastructure.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\3ce7727a\5d8f9942_a6f7d001\WebHelper.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\72c2229b\00c15643_f23ad001\System.Web.Mvc.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.DomainServices.Server\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.DomainServices.Server.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\84cc9ff5\003729d0_00c9d101\MySql.Data.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Data.SqlServerCe\4.0.0.0__89845dcd8080cc91\System.Data.SqlServerCe.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Deployment\v4.0_1.0.0.0__31bf3856ad364e35\System.Web.WebPages.Deployment.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\57169bbf\005b0492_f23ad001\System.Web.WebPages.Razor.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\1a877a98\0008f592_7daece01\Antlr3.Runtime.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\d3bafdd2\006926e2_e538d201\Microsoft.Data.OData.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\17aaa135\005b0492_f23ad001\System.Web.WebPages.Deployment.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.Activities.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\1034ad3d\005b0492_f23ad001\System.Web.WebPages.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\08931f20\007e29b7_f9ddd101\HtmlAgilityPack.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\442630b6\00fcae4b_f23ad001\System.Web.Razor.dll" /R:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\assembly\dl3\a665650f\00962356_ca90cf01\Glimpse.Core.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\10.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll" /out:"C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\App_Web_accessrequest.cshtml.f4cc22dc.wyu-er3-.dll" /D:DEBUG /debug+ /optimize- /w:4 /nowarn:1659;1699;1701;612;618 /debug:pdbonly /warnaserror-  "C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\App_Web_accessrequest.cshtml.f4cc22dc.wyu-er3-.0.cs" "C:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\App_Web_accessrequest.cshtml.f4cc22dc.wyu-er3-.1.cs"


Microsoft (R) Visual C# Compiler version 4.6.1590.0

for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.



This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

c:\Users\myNetworkAccount\AppData\Local\Temp\1\Temporary ASP.NET Files\vs\cdda6d1e\b9ef792f\App_Web_accessrequest.cshtml.f4cc22dc.wyu-er3-.0.cs(28,22): error CS0234: The type or namespace name 'Http' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

1 个答案:

答案 0 :(得分:0)

我解决了这个问题。 Views下的web.config包含一个旧的System.Web.Http.Data.Helpers命名空间。从web.config中删除它后,页面将被编译。感谢。

<pages pageBaseType="System.Web.Mvc.WebViewPage">
  <namespaces>
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Optimization" />
    <add namespace="System.Web.Routing" />
    <add namespace="System.Web.Http.Data.Helpers" />
  </namespaces>
</pages>​