Custom parameters

Hello,

I am using 

<SfPdfViewer ServiceUrl="/PdfViewer" DocumentPath="Blazor_Succinctly.pdf" Height="900px">

</SfPdfViewer>

as above. 

I want to know how to pass a custom parameter such as a string when the controller method is called to load this file?

Regards,

Amjad.



7 Replies

VS Vasugi Sivajothi Syncfusion Team October 22, 2021 01:17 PM UTC

Hi Amjad, 
 
Thank you for contacting Syncfusion support. 
 
In our PDF Viewer, there is no direct support to pass the parameter to the server in the blazor platform. However, you can achieve this as a workaround to pass the parameter from client to server using the below code snippet. We have shared the sample for your reference, please refer to the below link. 
 
Code Snippet in the client-side: 
 
<SfPdfViewer @ref="PdfViewer" ServiceUrl=http://localhost:55767/pdfviewer/parameter  DocumentPath="@DocumentPath"> 
</SfPdfViewer> 
 
 
Code Snippet in the server side: 
 
app.UseMvc(routes =>  
            {  
                routes.MapRoute("default", "{controller}/{id?}/{action}");  
            });   
 
 
public IActionResult Load(string id, [FromBody] Dictionary<string, string> jsonObject){  
} 
 
 
 
 
For more information, please refer to the below link. 
 
 
Kindly try this and let us know if this suits your requirement. If not, please share more details about your requirement. This will be helpful to assist you better. 
 
Regards, 
Vasugi. 
 



AK Amjad Khan October 23, 2021 05:23 AM UTC

Our application is using Endpoint Routing already in various controllers. So when I put your code snippet on the server side, it gives me this error:

"Using UseMvc to congifure MVC is not supported while using Endpoint routing. To continue using UseMvc, please set 'MvcOptions.EnableEndpointRouting=false' inside 'ConfigureServices'"


Regards,

Amjad.





AK Amjad Khan October 23, 2021 07:55 AM UTC

I think I need a sample app that works with the default Blazor Webassembly hosted app.


Thanks,

Amjad.



VS Vasugi Sivajothi Syncfusion Team October 25, 2021 12:54 PM UTC

Hi Amjad,  
 
Thank you for the update. 
 
Currently, we are checking the reported issue with the provided details. We will check further on this issue and provide the hosted sample to pass the parameter to the server in the blazor platform. 
 
Regards, 
Vasugi. 



VS Vasugi Sivajothi Syncfusion Team October 27, 2021 07:41 AM UTC

Hi Amjad,   
 
Thank you for your patience. We suggest you use the below code snippet to resolve the reported issue at your end. We have shared the hosted sample for your reference, please refer to the below code snippet and sample. 
 
Code Snippet in the client-side:  
 
<SfPdfViewer ServiceUrl = "/PdfViewer/parameter" DocumentPath="Blazor_Succinctly.pdf" Height="500px" Width="750px"> 
</SfPdfViewer> 
 
 
Code Snippet in the server side:  
Startup.CS: 
 
endpoints.MapControllerRoute( 
       name: "default", 
       pattern: "{controller=Home}/{id?}/{action=Index}"); 
 
 
PdfViewerController.cs 
 
[HttpPost("{id}/Load")] 
        [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")] 
        [Route("[controller]/{id}/Load")] 
        //Post action for Loading the PDF documents    
        public IActionResult Load(string id, [FromBody] Dictionary<string, string> jsonObject) 
        { 
} 
 
 
 
Kindly try this and let us know if you have any concerns about this. 
 
Regards, 
Vasugi. 



AK Amjad Khan replied to Vasugi Sivajothi October 27, 2021 05:03 PM UTC

Dear Support,


Thank you so much. This works great!


Regards,

Amjad.



VS Vasugi Sivajothi Syncfusion Team October 28, 2021 10:38 AM UTC

Hi Amjad, 
Thank you for the update. We are glad to know that the issue was resolved. Please revert to us if you need any further assistance. 
 
Regards, 
Vasugi. 


Loader.
Up arrow icon