C# 问题è;在发布的网站ASP.NET MVC中下载me
我在ASP.NET MVC应用程序中的操作下载有问题,在开发机器中它工作没有任何问题,但是当我将应用程序发布到IIS或从测试服务器进行测试时,我没有任何错误也没有例外,我只有一个白色窗口,在页面底部显示“witing for localhost…” 我的控制器动作C# 问题è;在发布的网站ASP.NET MVC中下载me,c#,asp.net-mvc-4,iis,publish,ms-publisher,C#,Asp.net Mvc 4,Iis,Publish,Ms Publisher,我在ASP.NET MVC应用程序中的操作下载有问题,在开发机器中它工作没有任何问题,但是当我将应用程序发布到IIS或从测试服务器进行测试时,我没有任何错误也没有例外,我只有一个白色窗口,在页面底部显示“witing for localhost…” 我的控制器动作 public ActionResult DownloadDocument(int idDocument) { try { DocumentVM Document = Se
public ActionResult DownloadDocument(int idDocument)
{
try
{
DocumentVM Document = ServiceApplicatif.getDocumentById(idDocument);
//Get document from virtual path
string FileName = ServiceFileUtilities.GetFileById(Document.StreamId);
DownloadResult drs = new DownloadResult //it's a file and it works
{
RootPath = rootDocuments, //rootDocuments is a path to filetable
ContentLength = Document.Length,
ContentType = Document.MimeType,
FileDownloadName = FileName,
FileName = FileName
};
return drs;
}
catch (Exception ex)
{
throw new Exception("Erreur : " + ex.message.toString());
}
}
我的观点很简单
<button onclick="myFunction()">Click me</button>
问题是由应用程序池标识引发的,您应该在机器服务器上为用户分配了权限当您直接从浏览器调用URL时会发生什么?另外,您正在测试哪个浏览器?“Waiting for localhost”(等待本地主机)意味着浏览器没有收到来自服务器的响应,服务器可能已崩溃或在未发送任何信息的情况下完成了执行。如果存在“Waiting for localhost”(等待本地主机),则您的下载URL肯定是错误的,并且没有指向生产服务器。请等待您的回复。那么,如何解释在dev机器中,服务器向我发回具有正确mimetype和all属性的文件。@Dusan当我调用URL时,它显示“网页不可访问”
function myFunction() {
var pageURL = url; //url with idDocument which is right
OpenPopupCenter(url, 'myWin', 600, 800);
}
function OpenPopupCenter(pageURL, title, w, h) {
var left = (screen.width - w) / 2;
var top = (screen.height - h) / 4; // for 25% - devide by 4 | for 33% - devide by 3
var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no,adressbar=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
targetWin.document.title = "Document";
}