Vulnerability in EPiServer.Forms
I use EPiServer.ImageLibrary ImageServiceClient RenderImage method to render a cropped image. This was the code before upgrade to EPiServer CMS 11.5 and this was working fine.
var imageService = new ImageServiceClient("ImageServiceClientEndPoint");
After the upgrade, this code shows a compile error;
'ImageServiceClient.ImageServiceClient(string)' is obsolete: 'Use constructor that takes options instead, read options from container'
Accordingly, I changed the code as follows;
ImageServiceOptions options = new ImageServiceOptions();
options.ClientEndpoint = "ImageServiceClientEndPoint";
var imageService = new ImageServiceClient(options);
Then I was able to compile successfully. But now this throws this exception;
System.InvalidOperationException: 'Could not find endpoint element with name 'ImageServiceClientEndPoint' and contract 'EPiServer.ImageLibrary.IImageService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.'
What have I done wrong here?
Do you have something like the following in your web.config:
<binding name="ImageServiceBinding" maxReceivedMessageSize="20000000">
<readerQuotas maxArrayLength="20000000" />
Thanks for the reply. I added this endpoint configuration to web.config and now the System.InvalidOperationException is fixed.
However the imageService.RenderImage() method now returns a null.
byte newImageBuffer = imageService.RenderImage(imageBuffer, operations, imageMimeType, zoomFactor, 100);
This method correctly worked when using the ImageServiceClient("ImageServiceClientEndPoint") constructor before EPiServer upgrade. Am I missing something?
Do you also have the image service itself configured in <system.serviceModel>?
No. Now I added ImageService configuration as well.
But the RenderImage() method still returns a null.
Any error message in the logs?
The setting ClientEndpoint property on ImageServiceOptions is to be used if you want to host the ImageService in another application/process as your web application, in that case you need to specify an endpoint in web.config as stated before. You can also (which is the default behavior) run the image service in-process then you just leave the ClientEndpoint property empty/null on then imageServiceOptions class.