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 404 - /api/PdfViewer/Load

Hi !
Like said the title, I got an error in my web, when I try to see my PDF in my FileExplorer, open a new windows, but dont show anything, so, when i go to the console, I got this error :
api/PdfViewer/Load:1 - 404

My code is:

<%@ Register Assembly="Syncfusion.EJ.Web, Version=17.2460.0.34, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" Namespace="Syncfusion.JavaScript.Web" TagPrefix="ej" %>
     
   
           
           
       
 
       
   
       
       
       
       
   
   

And my Controller is :

using Newtonsoft.Json;
using Syncfusion.EJ.PdfViewer;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace WebApplication1.SysAdmin
{
public class PdfViewerController1 : ApiController
{
public object Load(Dictionary jsonResult)
{
PdfViewerHelper helper = new PdfViewerHelper();
//load the multiple document from client side
if (jsonResult.ContainsKey("newFileName"))
{
var name = jsonResult["newFileName"];
var pdfName = name.ToString();
string urlLink = Url.Content("~/") + "FileBrowserAdministracion/" + pdfName;

var WebClient = new WebClient();

//converts the url to byte array

byte[] pdfDoc = WebClient.DownloadData(urlLink);

//loads the byte array in PDF Viewer

helper.Load(pdfDoc);
}
else
{
if (jsonResult.ContainsKey("isInitialLoading"))
{
if (jsonResult.ContainsKey("file"))
{
string urlLink = Url.Content("~/") + jsonResult["file"].ToString().Substring(jsonResult["file"].ToString().IndexOf("/") + 1);

var WebClient = new WebClient();

//converts the url to byte array

byte[] pdfDoc = WebClient.DownloadData(urlLink);

//loads the byte array in PDF Viewer

helper.Load(pdfDoc);
}
else
{
string urlLink = Url.Content("~/") + "content/images/FileExplorer/pdf/HTTP Succinctly.pdf";

var WebClient = new WebClient();

//converts the url to byte array

byte[] pdfDoc = WebClient.DownloadData(urlLink);

//loads the byte array in PDF Viewer

helper.Load(pdfDoc);
}
}
}

string output = JsonConvert.SerializeObject(helper.ProcessPdf(jsonResult));
return output;
}
public object Download(Dictionary jsonResult)
{
PdfViewerHelper helper = new PdfViewerHelper();
return helper.GetDocumentData(jsonResult);
}
public object FileUpload(Dictionary 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);
}
string output = JsonConvert.SerializeObject(helper.ProcessPdf(jsonResult));
return output;
}
}
}
The problem not is the FileExplorer, the problem is, that I can't open the PDF.


5 Replies

AA Akshaya Arivoli Syncfusion Team October 9, 2019 02:01 PM UTC

Hi Eduardo, 

Thank you for contacting Syncfusion support. 

We are unable to reproduce the reported issue with the details provided. We have created sample to view the PDF documents available in File Explorer in PDF Viewer control in ASP.NET Web Forms and shared the same in the following location.  


Note: Kindly ensure whether the Scripts. CSS and the Packages of same version referred in your project. Also please ensure whether the web api controller is mapped properly in the serviceUrl of your project 

Please try with the provided sample and revert us with the modified sample and the error details if you are still facing the issue. These details will be helpful for us to investigate more on your issue and assist you better. 

Please revert us if you have any concerns on this. 

Regards, 
Akshaya 



EM eduardo manuel leon cuya October 9, 2019 10:49 PM UTC

Now I got this error :



And when I access the site "Load" I got this:

The requested resource does not support the 'GET' http method.

How I can Fix it ?

You can login here and see the error:

https://www.zeta.pe/Account/Login

User: test
Pass: 123123


AA Akshaya Arivoli Syncfusion Team October 10, 2019 01:32 PM UTC

Hi Eduardo,  
  
We have checked the provided link and found that exception is thrown in server side of the project so “PdfViewer throws the 500 error”. Also, we suspect that the issue is due to the using of WebClient (WebClient.DownloadData(urlLink)) to download the document and to load in the PDF Viewer. So instead of downloading the file, please try to load the PDF document using the file path. Please use the below code snippet in the Load() of the WebApi Controller. 
  
public object Load(Dictionary<stringstring> jsonResult)   
        {   
            PdfViewerHelper helper = new PdfViewerHelper();   
            //load the multiple document from client side    
            if (jsonResult.ContainsKey("newFileName"))   
            {   
                var name = jsonResult["newFileName"];   
                var pdfName = name.ToString();                  
                string path = HttpContext.Current.Server.MapPath("~/content/images/FileExplorer/" + pdfName);                
                helper.Load(path);   
            }   
            else   
            {   
                if (jsonResult.ContainsKey("isInitialLoading"))   
                {   
                    if (jsonResult.ContainsKey("file"))   
                    {   
                        string path = HttpContext.Current.Server.MapPath("~/" + jsonResult["file"].ToString().Substring(jsonResult["file"].ToString().IndexOf("/") + 1));                           
                        helper.Load(path);   
                    }   
                    else   
                    {   
                        string path = HttpContext.Current.Server.MapPath("~/content/images/FileExplorer/pdf/HTTP Succinctly.pdf");                       
                        helper.Load(path);   
                    }   
                }   
            }    
            string output = JsonConvert.SerializeObject(helper.ProcessPdf(jsonResult));   
            return output;   
        }   
  
  
Please try with the provided suggestion and revert us with the modified sample and confirm us whether you are facing the reported error locally or while hosting the project. These details will be helpful for us to investigate more on your issue and assist you better. 
  
Regards, 
Akshaya 
1


EM eduardo manuel leon cuya October 10, 2019 03:22 PM UTC

Still have the same issue, so I send the files to see where is the error.



Attachment: syncfusion_27dd5d2c.zip


AA Akshaya Arivoli Syncfusion Team October 11, 2019 09:53 AM UTC

Hi Eduardo, 

We have created new incident under your account. Please log on to our support website to check for further updates about the reported issue.      
http://www.syncfusion.com/Account/Logon?ReturnUrl=%2fsupport%2fdirecttrac 

Please revert us if you have any concerns on this. 

Regards, 
Akshaya 


Loader.
Live Chat Icon For mobile
Up arrow icon