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

Issues creating asp.net core web service for PDF Viewer

I am having two issues:
  • I get a 400 when the PDF Viewer (see pdf-viewer.html) attempt to call the web service PdfViewerController.  If I use your online web service, the simple viewer works properly.
  • If I launch the viewer from a different web site (some other port on local host) I get CORS errors.
This is on Mac OS (latest) and Visual Studio 2019 with .net core 3.1.

I have reviewed various threads and downloaded various services, none seem to work.

I have attached my test, but again, this is on a Mac.  I had limited success hosting from Windows (embedded viewer worked, still had CORS issues, I googled, no luck).

Thank you for your time.

Kenneth Russo

Attachment: PdfViewerService_660c375f.zip

3 Replies

KR Kenneth Russo January 24, 2020 04:00 AM UTC

Actually table the CORS issue for now, lets just focus on getting the api working on asp.net core.  Thanks Ken

SD Samantha Digby Syncfusion Team January 24, 2020 02:52 PM UTC

Incident 262261 has been created for this forum.  

RG Rajasekar G Syncfusion Team January 24, 2020 03:58 PM UTC

Hi Kenneth, 
Sorry for the inconvenience,  
To resolve this issue, you have to configure the cross origin and controller routing in startup.cs. Also refer the Microsoft.AspNetCore.Mvc.NewtonsoftJson package with version 3.1.1 for parsing the JSON object in controller. Please find the code snippet below.  
public class Startup 
        public Startup(IConfiguration configuration) 
            Configuration = configuration; 
        public IConfiguration Configuration { get; } 
        readonly string MyAllowSpecificOrigins = "MyPolicy"; 
        // This method gets called by the runtime. Use this method to add services to the container. 
        public void ConfigureServices(IServiceCollection services) 
            services.AddControllers().AddNewtonsoftJson(options => 
                // Use the default property (Pascal) casing 
                options.SerializerSettings.ContractResolver = new DefaultContractResolver(); 
            services.AddCors(options => 
                builder => 
            services.Configure<GzipCompressionProviderOptions>(options => options.Level = System.IO.Compression.CompressionLevel.Optimal); 
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 
            if (env.IsDevelopment()) 
            app.UseEndpoints(endpoints => 
We have created the simple PDF viewer web service application in .NET core 3.1 and provided in the below link. 
Note: Run the PDF viewer web service application and provide the launched URL to the serviceUrl property of PDF viewer control. 
Please try the provided web service application in your and provide the more details if it still facing problem on web service in your environment. 

Live Chat Icon For mobile
Up arrow icon