javascript - 在本地但在服务器上完美运行:加载资源失败:500(内部服务器错误)
问题描述
我有一个 MVC5 Web 应用程序,我已经工作了一段时间。当我在本地工作时,它完美无缺。但是当我将它发布到我们公司的服务器时,在我打印收据的部分中,我有“加载资源失败”错误。正如我所说,当我在本地工作时,它工作得很好。我使用 devexpress xtrareport .print() 方法打印收据。以下是我使用的一些代码:
POST 方法,这是我得到错误的视图:
function result() {
$(document).ready(function () {
value = document.getElementById('tutar').value;
var value3 = document.getElementById('bankalar').value;
var value2 = parseFloat(value);
try {
value1 = document.getElementById('1001').innerHTML;
} catch {
value1 = "Girilmedi";
}
if (document.getElementById("musteriAdi0").value == "") {
alert("Müşteri Adı Girilmeden İşlem Yapılamaz");
for (var u = p; u < i; u++) {
try {
var element = document.getElementById(u);
var row = element.parentNode.parentNode;
row.parentNode.removeChild(row);
} catch {
}
}
window.location.href = '@Url.Action("HizliAlimSatim", "Kuyumcu")';
}
else {
ekle();
var m = JSON.stringify({
'model': things, 'toplam': value2, 'personel': value1, 'KrediKarti': value3
});
things = [];
$(function () {
$.ajax({
type: "POST",
url: "/Kuyumcu/HizliAlimSatim",
contentType: "application/json; charset=utf-8",
dataType: "Json",
data: m,
success: function (data) {
if (data.includes("/Kuyumcu/Document") == false) {
g = g - i;
} else {
alert("İşlem Başarılı!");
//window.open(data, '_blank');
document.getElementById('tutar').value = 0;
toplam = 0;
degistir();
for (var u = p; u < i; u++) {
try {
var element = document.getElementById(u);
var row = element.parentNode.parentNode;
row.parentNode.removeChild(row);
} catch {
}
}
p = i;
window.location.reload(true);
}
}
});
});
}
});
}
这是我调用打印方法的控制器:
Fis report = new Fis();
report.Parameters["FisNo"].Value = id;
report.Parameters["Musteri"].Value = model[0].MusteriAdSoyad;
report.Parameters["Islemci"].Value = personel;
report.CreateDocument(false);
//report.ShowPreview();
report.PrintingSystem.ShowMarginsWarning = false;
report.Print();
return Json(Url.Action("Document", "Kuyumcu");
我一直在尝试解决这个问题 2 天,我认为这是一个服务器端问题,但无论我改变什么都没有用。
解决方案
The XtraReport.Print method from your controller is invoked at the server side - that's why it works when you run your application on localhost. When you deploy it to the production server, the Print method will be executed at the server's machine - not the client one.
Assuming that you use a DocumentViewer to display a report on your web page, use the viewer's client-side API (see the Print method) to print a report. For instance, refer to the sample code snippet from the How to display print dialog after the WebDocumentViewer is loaded on the web page thread.
If you want to print a report without displaying it, use the approach shown in the following example.
推荐阅读
- android - Xamarin App Android 上的输入调度超时错误
- reactjs - 当我调用 DrawerOpen 时,抽屉不会打开到 initialRouteName
- bootstrap-4 - Bootstrap 4 - 具有固定边距的动态居中列数
- javascript - 上传 HTML 格式的图片并获取图片路径
- jmx - 每分钟将数据记录到 grafana
- android - 房间更新后将回收站视图滚动到新位置
- laravel - laravel errno: 150 "外键约束格式不正确
- sql-server - 导出到 CSV/Excel 时如何保持 SQL 格式
- c# - LINQ-to-SQL 插入...选择...其中...在一个查询中
- python - 创建后分配外键值(登录用户)