这是我在 MVC 应用程序中下载文件的代码。我有一个奇怪的错误,我无法纠正它。错误是 > 无法将类型“System.Web.Mvc.RedirectToRouteResult”隐式转换为“System.Web.Mvc.FileResult”
我想要这段代码是,虽然有一个文件下载它,但如果没有文件(null)那么它什么也不做或什么也不返回
public FileResult Download(string Doc)
{
string fullPath = Path.Combine(Server.MapPath("~/UploadFiles/"), Doc);
if (fullPath == null)
{
byte[] fileBytes = System.IO.File.ReadAllBytes(fullPath);
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, Doc);
}
return RedirectToAction("List");
}