Picture box 403 error

1 Answer 40 Views
Rendering Report Designer (standalone)
son
Top achievements
Rank 1
Iron
Iron
son asked on 28 Oct 2024, 08:28 AM

Hi anyone,

I have a problem with picture box, I put a url of a png file in picture box, but it always gives 403 error every time I when try to call renderReport function of ReportProcessor class.

Everything still works fine on Report designer, does anyone know how to fix this, i am using version 16.1.22.511.

Thank you.

Son

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 Oct 2024, 03:48 PM

Hello, Son,

Following the provided information, I have prepared a sample report that contains a PictureBox with URL image content as value. The report is successfully processed and the image is exported OK in the PDF result for example. A sample project with my report is attached. Please give it a try and see how it works on your end.

However, I would like to note that depending on the URL itself, e.g. when the URL contains percent encoded path delimiters - forward slash / encoded as %2F) the request will fail with 400 Bad Request, 404 Not Found, or yield another unexpected result. The following KB article gives more information on this case: Unable to Use URL With Encoded Characters in PictureBox.

The HTTP 403 Forbidden client error response status code indicates that the server understood the request but refused to process it. This status is similar to 401, except that for 403 Forbidden responses, authenticating or re-authenticating makes no difference.

The following KB also handles a similar problem with the images: Picturebox Throws Error 401 Unauthorized.

You can use the suggested approach for assigning the image value:

string url = @"your url";
System.Net.WebRequest request = System.Net.WebRequest.Create(url);
System.Net.WebResponse response = request.GetResponse();
System.IO.Stream responseStream = response.GetResponseStream();

Bitmap bitmap = new Bitmap(responseStream);

PictureBox pb = report.Items.Find(typeof(PictureBox),true).FirstOrDefault() as PictureBox;
pb.Value=(bitmap);

If this is not the exact scenario you have, it would be greatly appreciated if you can provide the exact URL you are currently using. Thus, we would be able to make an adequate analysis of the precise case and provide further assistance. Thank you in advance.

Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Stay tuned by visiting our roadmap and feedback portal pages, enjoy a smooth take-off with our Getting Started resources, or visit the free self-paced technical training at https://learn.telerik.com/.
son
Top achievements
Rank 1
Iron
Iron
commented on 30 Oct 2024, 01:53 AM

Thank you Dess, I will try and will let you know if it can fix my issue.

I appreciate your help.

Dess | Tech Support Engineer, Principal
Telerik team
commented on 30 Oct 2024, 04:05 PM

Take as much time as you need. Please let me know if you need any further assistance. 
son
Top achievements
Rank 1
Iron
Iron
commented on 31 Oct 2024, 02:27 AM | edited

Thank you,

Following your anwser, I have some picture boxs in a template, how to find a specific picture box? I am just a newbie in .net core.

 

Dess | Tech Support Engineer, Principal
Telerik team
commented on 01 Nov 2024, 10:08 AM

Hi, Son,

I would recommend you to have a look at the following article that shows how to access a specific report item from within the report and from the invoking application: Access Report Items Programmatically.

The Find method can accept a string parameter which represents the name of the respective PictureBox. Passing a second boolean parameter with value=true will ensure recursive traversing of the Items collection.

I hope this information helps.

Tags
Rendering Report Designer (standalone)
Asked by
son
Top achievements
Rank 1
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or