HttpPostedFileBase 缺少参考

Dor*_*anu 4 c# asp.net asp.net-core

我收到一个错误HttpPostedFileBase

找不到类型或命名空间名称“HttpPostedFileBase”(您是否缺少 using 指令或程序集引用?)

我已经尝试使用,using System.Web但根本不起作用。

编辑 #1

public IActionResult Upload(HttpPostedFileBase file)
    {

        if (file.contentlength > 0)
        {
            var filename = Path.GetFileName(file.filename);
            var path = Path.Combine(Server.mappath("~/app_data/uploads"), filename);
            file.saveas(path);
        }

        return RedirectToAction("index");
    }
Run Code Online (Sandbox Code Playgroud)

我实际上没有参考文件没有参考文件夹

Cod*_*ter 10

您不能混合搭配教程和框架版本。您使用的是 ASP.NET Core 2.0.8,其中不包含HttpPostedFileBase.

ASP.NET Core 对应物HttpPostedFileBaseIFormFile.