We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Error 500

Hello,

I use, Syncfusion.EJ.PdfViewer version 17.3460.0.19 and .Net version 4.6.1. 
I followed the documention to display a pdf on pdfviewer. In local the pdf is well displayed but on my server I obtain a error 500 for api/pdfviewer/Load, I don't understand why I have this error. 


In my page I have :

<ej:PdfViewer Height="700" id="PdfViewer" runat="server" ServiceUrl="../api/PdfViewer" PdfService="Local" SignatureAdd="signatureAdded">
 </ej:PdfViewer>

In my PdfViewerController :

    public class PdfViewerController : ApiController
    {
        //Post action for processing the PDF documents.
        public object Load(Dictionary<string, string> jsonResult)
        {
            PdfViewerHelper helper = new PdfViewerHelper();
            //load the multiple document from client side 
            if (jsonResult.ContainsKey("newFileName"))
            {
                var name = jsonResult["newFileName"];
                var pdfName = name.ToString() + ".pdf";
                helper.Load(HttpContext.Current.Server.MapPath("~/Data/" + pdfName));
            }
            else
            {
                if (jsonResult.ContainsKey("isInitialLoading"))
                {
                    if (jsonResult.ContainsKey("file"))
                    {
                        string name = HttpContext.Current.Server.MapPath("~/Data/" + jsonResult["file"].ToString().Substring(jsonResult["file"].ToString().IndexOf("/") + 1));
                        helper.Load(name);
                    }
                    else
                    {
                        helper.Load(HttpContext.Current.Server.MapPath("~/Data/EULA_OTPOne_EN.pdf"));
                    }
                }
            }
            return JsonConvert.SerializeObject(helper.ProcessPdf(jsonResult));
        }

        //Post action for processing the PDF documents when uploading to the ejPdfviewer widget.
        public object FileUpload(Dictionary<string, string> jsonResult)
        {
            PdfViewerHelper helper = new PdfViewerHelper();
            if (jsonResult.ContainsKey("uploadedFile"))
            {
                var fileUrl = jsonResult["uploadedFile"];
                byte[] byteArray = Convert.FromBase64String(fileUrl);
                MemoryStream stream = new MemoryStream(byteArray);
                helper.Load(stream);
            }
            return JsonConvert.SerializeObject(helper.ProcessPdf(jsonResult));
        }

        //Post action for downloading the PDF documents from the ejPdfviewer widget.
        public object Download(Dictionary<string, string> jsonResult)
        {
            PdfViewerHelper helper = new PdfViewerHelper();
            return helper.GetDocumentData(jsonResult);
        }

        //Post action for unloading and disposing the PDF document resources in server side from the ejPdfviewer widget.
        public void Unload()
        {
            PdfViewerHelper helper = new PdfViewerHelper();
            helper.UnLoad();
        }
    }

In my global :
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteTable.Routes.MapHttpRoute(name: "StripeWebhooks", routeTemplate: "api/{controller}/");
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("mylicencekey");

            GlobalConfiguration.Configuration.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{action}/{id}",
            defaults: new { id = RouteParameter.Optional });
        }



1 Reply

AA Akshaya Arivoli Syncfusion Team November 13, 2019 12:12 PM UTC

Hi JudicaelG, 

Thank you for contacting Syncfusion support. 

Based on the provided details we suspect that the Web API controller is not mapped properly in the production environment, so kindly ensure whether it is mapped properly. Map the controller absolutely in the production environment by using the VirtualPathUtility.ToAbsolute(). Please find the below UG link for more details, 


Please try this and revert us with more details or the sample in which you are facing the issue . These details will be helpful for is to investigate more on your issue and assist you better. 

Regards, 
Akshaya 


Loader.
Up arrow icon