C# - I cannot reference HttpPostedFileBase

流过昼夜 提交于 2019-11-29 06:18:27

Make sure your project references the System.Web.Abstractions assembly which contains the HttpPostedFileBase type.

As confusing as it may seem, the HttpPostedFile type lives in a separate assembly (System.Web) but the same exact namespace.

It is important to remember that the namespaces can span assemblies and the name of an assembly does not necessarily dictate the namespace of the types contained in it. There is no System.Web.Abstractions namespace simply two assemblies that contain types in the System.Web namespace.

Once you have referenced both assemblies you can reference both types by their unqualified names with this single using statement:

using System.Web;

Make sure your project references the System.Web.Abstractions assembly which contains the HttpPostedFileBase type.

Thanks, Andrew Hare, that did the trick, yet I believe that from .Net 4.0 and so on, System.Web.Abstractions is deprecated, and you should add reference to System.web instead.

In my case, that was the ultimate solution, after that

using System.Web;

worked, and therefore, HttpPostedFileBase was recognized.

Thanks.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!