在 IIS7 中部署后文件附件不起作用

File attachments not working after deployment in IIS7

使用以下代码附加文件。当我从 visual studio 运行应用程序时它工作正常。我在 IIS7 中(在我的机器中)部署了应用程序。从部署站点,我无法附加文件。请让我知道如何解决这个问题。 查看:

 $("#lnkAddAttachment").click(function (e) 
 {
    oFiles = document.getElementById("txtFile").files[0],
    nFiles = oFiles.size;

var selectedFile = document.getElementById("txtFile").files[0];
    var size = selectedFile.size;
    var name = selectedFile.name;
    var type = selectedFile.contentDocument;

var xhr = new XMLHttpRequest();
    var fd = new FormData();
    fd.append("file", document.getElementById('txtFile').files[0]);
    xhr.open("POST", "/ESignature/getFile/", true);
    xhr.send(fd);
    xhr.addEventListener("load", function (event) {
        }, false);


    var url = '@Url.Content("~/")' + "ESignature/Registration";
    $('#gridAttachments').load(url + ' #gridAttachments');


$('#txtDescription').val('');
    $('#txtFile').val('');
    return false;
})

控制器:

    [HttpPost]
    public ActionResult getFile(HttpPostedFileBase file)
    {
        BRUser brUser = new BRUser(); 
            AttachedFile attachedFile = new AttachedFile();

            attachedFile.FileType = "Passport";
            attachedFile.Filename = System.IO.Path.GetFileName(@DateTime.Now.Ticks + file.FileName);
            attachedFile.Filesize = (file.ContentLength / 1024);
            file.SaveAs(Server.MapPath("~/ESignatureUploads/" + attachedFile.Filename));
            attachedFile.Filepath = "~/ESignatureUploads/" + attachedFile.Filename;

            if (Session["ESAttachedFiles"] != null)
            {
                brUser.AttachedFiles = (List<AttachedFile>)Session["ESAttachedFiles"];
            }

            brUser.AttachedFiles.Add(attachedFile);
            Session["ESAttachedFiles"] = brUser.AttachedFiles;
            return View("Registration", brUser);
 }

    [HttpGet]
    public ActionResult Registration()
    { 
            BRUser objuser = new BRUser();             
            if (Session["ESAttachedFiles"] != null)
            {
                objuser.AttachedFiles = (List<AttachedFile>)Session["ESAttachedFiles"];
                TempData.Keep();
            }
            return View(objuser);

    }

在下面的函数中,

$("#lnkAddAttachment").click(function (e) 

我从

更改了 url
xhr.open("POST", "/ESignature/getFile/", true);

 xhr.open("POST", "~/ESignature/getFile/", true);

它解决了我的问题。