Getting error AmbiguousMatchException when loading for second time a PDf

Hello,

I'm using the PdfViewer to load a new created Pdf dynamically, from a list of icons.

When Click on one icon I am able to load the PDf and show it on the PdfViewer, when click on a second icon for testing I create the same PDf dynamically and pass it to the Pdfviewer to show it, it is there when I get the AmbiguousMatchException error.


I'm using the Pdfviewer from Blazor Wasm that calls the PdfViewerController that I create on a separate project.

This is the error:

Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware: Error: An unhandled exception has occurred while executing the request.


Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints. Matches:


Server.Controllers.PDFViewerController.ImportFormFields (Server)

Server.Controllers.PDFViewerController.Unload (Server)

Server.Controllers.PDFViewerController.ExportFormFields (Server)

Fallback {*path:nonfile}

   at Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ReportAmbiguity(CandidateState[] candidateState)

   at Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ProcessFinalCandidates(HttpContext httpContext, CandidateState[] candidateState)

   at Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.Select(HttpContext httpContext, CandidateState[] candidateState)

   at Microsoft.AspNetCore.Routing.Matching.DfaMatcher.MatchAsync(HttpContext httpContext)

   at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext)

   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)

   at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context)

   at Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware.Invoke(HttpContext context)

   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)

   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Using

Snippet
<PackageReference Include="Syncfusion.Blazor.Core" Version="20.1.0.61" />
Snippet
<PackageReference Include="Syncfusion.Blazor.PdfViewer" Version="20.1.0.61" />
Snippet
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="20.2.0.39" />


Please Help


7 Replies

VV Visvesvar Venkatesan Syncfusion Team September 19, 2022 02:41 PM UTC

Hi Luis Campuzano,


We suspect there are two or more API endpoints having same name in multiple places. So we could not able to predict the changes that you have made on your sample. So could you please share simple sample along with the web service sample you have used, that would helpful to resolve your issue at earliest.


https://stackoverflow.com/a/59283768



Regards,

Visvesvar K V



LC Luis Campuzano September 19, 2022 04:57 PM UTC

Hi, Visvesvar Venkatesa


Please see attached zip file with a sample project with the same errors,


I have the AgreementDocuments.razor as the main page, when click on the Edit icon (the red one) from the left list, will load the pdf fine, when click again on another Edit Icon it is when the error happening and you can see on the Output the Ambigous error.

I am using Blazor Wasm Hosted (Net6).

Also, the PdfServices is on the PdfViewerController


Attachment: AmbiguousMatchException_79494010.zip


VV Visvesvar Venkatesan Syncfusion Team September 21, 2022 12:34 PM UTC

 

Hi Luis Campuzano,

 

We didn’t get the exception or the issue with your sample. But we suspect the issue is caused due to the below code available on the BlazorApp1\Server\Controllers\PdfViewerController.cs file. Please use the below highlighted changes to resolve your issue.

 

 



Regards,

Visvesvar K V



LC Luis Campuzano September 21, 2022 04:59 PM UTC

Hi  Visvesvar Venkatesan,


Those changes helps to fix that issue, but now I don't know if it is the PdfViewer or something else is hanging because I can't scroll down or do anything on the PdfViewer, I have to refresh the page.


Thanks for your help


Regards,


Luis



SK Sinthiya Kalimuthu Syncfusion Team September 22, 2022 01:23 PM UTC

Hi Luis,


Kindly remove the code ID = “pdfviewer” at testcomponent.razor file to resolve the issue.


We have attached a screenshot of it.


Kindly remove the highlighted code as mentioned in this image.




After removing this the scrolling works fine. Kindly revert to us if you still face any issues, We are here to assist you.


Regards,

Sinthiya K



LC Luis Campuzano September 22, 2022 02:02 PM UTC

Hi Sinthiya K,


Thanks, that fix the issue, I was wonder why the Id will break the Component?


Thanks for all your help,


Regards,


Luis



SK Sinthiya Kalimuthu Syncfusion Team September 23, 2022 06:06 AM UTC

Hi Luis,


Thanks for the update. Kindly revert to us if you have further queries.


Regards,

Sinthiya K


Loader.
Up arrow icon