Asp.net .net网站抛出404错误

Asp.net .net网站抛出404错误,asp.net,.net,file,iis,download,Asp.net,.net,File,Iis,Download,我有一个工作网站,我可以上传和下载文件到本地项目内的文件夹。然而,当我使用IIS在局域网上托管网站时,我在尝试下载文件时遇到404错误-我可以很好地上传文件,并且它们显示在正确的文件夹中 错误: HTTP错误404.0-未找到您正在查找的资源已被删除 已删除、名称已更改或暂时不可用 这是我的控制器 下载控制器: [HttpGet] public virtual ActionResult Download(string file) { string fullPath = Path.Comb

我有一个工作网站,我可以上传和下载文件到本地项目内的文件夹。然而,当我使用IIS在局域网上托管网站时,我在尝试下载文件时遇到404错误-我可以很好地上传文件,并且它们显示在正确的文件夹中

错误:

HTTP错误404.0-未找到您正在查找的资源已被删除 已删除、名称已更改或暂时不可用

这是我的控制器

下载控制器:

[HttpGet]
public virtual ActionResult Download(string file)
{
    string fullPath = Path.Combine(Server.MapPath("~/SupportAttachments/"), file);
    return File(fullPath, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", file);
}
[HttpPost]
public JsonResult UploadFiles(string id)
{
    try
    {
        foreach (string file in Request.Files)
        {
            var hpf = Request.Files[file] as HttpPostedFileBase;
            if (hpf.ContentLength == 0)
                continue;
            var fileContent = Request.Files[file];
            if (fileContent != null && fileContent.ContentLength > 0)
            {
                // get a stream
                var stream = fileContent.InputStream;
                // and optionally write the file to disk
                var fileName = id + " " + hpf.FileName;
                var path = Path.Combine(Server.MapPath("~/SupportAttachments/"), Path.GetFileName(fileName));

                // Save the file
                hpf.SaveAs(path); 
            }
        }
    }
    catch (Exception)
    {
        Response.StatusCode = (int)HttpStatusCode.BadRequest;
        return this.Json("Upload failed");
    }

    return this.Json("File uploaded successfully");
}
上载控制器:

[HttpGet]
public virtual ActionResult Download(string file)
{
    string fullPath = Path.Combine(Server.MapPath("~/SupportAttachments/"), file);
    return File(fullPath, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", file);
}
[HttpPost]
public JsonResult UploadFiles(string id)
{
    try
    {
        foreach (string file in Request.Files)
        {
            var hpf = Request.Files[file] as HttpPostedFileBase;
            if (hpf.ContentLength == 0)
                continue;
            var fileContent = Request.Files[file];
            if (fileContent != null && fileContent.ContentLength > 0)
            {
                // get a stream
                var stream = fileContent.InputStream;
                // and optionally write the file to disk
                var fileName = id + " " + hpf.FileName;
                var path = Path.Combine(Server.MapPath("~/SupportAttachments/"), Path.GetFileName(fileName));

                // Save the file
                hpf.SaveAs(path); 
            }
        }
    }
    catch (Exception)
    {
        Response.StatusCode = (int)HttpStatusCode.BadRequest;
        return this.Json("Upload failed");
    }

    return this.Json("File uploaded successfully");
}

有人能告诉我为什么通过IIS托管时无法下载文件吗?

我建议尝试按此处所述进行修复-@victork感谢您的建议,但我只是尝试了一下,没有什么不同