首页 > 解决方案 > 在本地但在服务器上完美运行:加载资源失败: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 天,我认为这是一个服务器端问题,但无论我改变什么都没有用。

标签: javascriptasp.net-mvchttp-postasp.net-ajax

解决方案


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.


推荐阅读