Loading Images for Silverlight app from server without ssl - silverlight

I have an Silverlight application that uses ssl to communicate with the site-of-origin. The application loads a number of images from a separate server (running apache under port 81 without ssl). The images are regular png's. The images from the Apache machine are not loaded properly, i.e. the image control remains blank. When I post the same image on my app server (i.e. site-of-origin), and modify the link accordingly, the images are displayed properly. This link on MSDN says that images are media are excluded from access-restriction policies.
Would appreciate any suggestions.

I hope you are deploying your Silverlight application to a web server and not running it using the Visual Studio development server. I had a similar problem with images when I was using the built in development web server. You can find about my experience here.
It might help if you subscribe to ImageFailed event and post the stacktrace.

You are running into cross-scheme access restrictions in silverlight, see table at the bottom of http://msdn.microsoft.com/en-us/library/cc189008(v=vs.95).aspx
One possible solution is to load image using WebClient and call SetSource on image element. That is what we do in our app. In fact we wraped it into custom image control that hides all annoying details.

Related

Winappdriver and selenium in the same automated test

Hi I could do with some help / more experienced eyes.
I have a WPF application which I have started automating some UI tests for using winappdriver, upon further investigation it has embeded html in it - webview, and can fire off requests to open the default browser with app related content - such as help files.
Has anyone had experience in working with this? For example:
open the WPF app,
click on help button on the WPF app which will open a browser and
then continue the test to ensure that the correct help page has been launched with the correct content in relation to the WPF page it was fired from.
Presumably this can be done in my case with chrome driver (winappdriver cannot see the content on the webpage). I have tried using selenium's window handles, but it's like the driver can't see the already open browser page. So I am at a bit of a loss and really not sure what to do.
In previous roles I was used to using Ranorex, which does both windows and web based UI automation. So I have never had any experience using multiple driver types to do the one test.

How to use chromium engine inside google chrome to render my application

I wonder if it is possible to use chromium engine inside google chrome or the google chrome itself to render a web page inside my WPF application instead of using traditional WebView (because it's the IE engine and it's awful -_-) or implementing CEFSharp (because it uses about 200 MB of space only for the chromium engine)
so in this case I need the target pc to has installed google chrome or any other(firefox or ...)
Soooo ... is there any solution?
thanks in advance
EDIT
I want to create applications based on web UI, - because of being easy and powerful - I know some providing this feature, e.g. CEF Sharp WPF or electron js but they include a full chromium engine with the app. I don't want this.
I want to create my app as light as possible, and my idea is to use chromium engine of a modern browser, that almost everyone has one.
For example, imagine that the user has installed google chrome.
first I locate the installation folder
I use chromium.exe -render path/to/file.html(imaginary) command to render my application UI.
finally bind the UI events to my native code. (e.g. c#(wpf) or any language that you can create desktop apps with it)
One solution is creating web apps by installing a website with the browser. but with that you cannot for example create or read some files in user pc, or any similar operation.
I'm looking for the most light-weight solution...
There is a new Chromium based WebView2 control that you can use to embed modern web content in your WPF application.
Please refer to the docs for more information about the prerequisites and how to use it:
Getting started with WebView2 in WPF
Explanation
So, let's say that you want your UI to be rendered in a chromium environment(aka a browser)… right?
let's take a look at electron js:
it uses NodeJS as backend.
it uses an embedded browser for frontend.
the language used is JavaScript due to NodeJS.
So, you want to use the client's browser to render your frontend instead of embedding a browser inside it.
well, don't embed it!!
you can create a web application(e.g. opened by typing localhost:<port> in browser1) using NodeJS and handle your IPC(between frontend and backend) using ajax calls or a socket connection.
that way you are doing exactly what an electron app does, except that, electron uses a bundled browser.
now you made your app lighter, also if your client do have NodeJS installed, you don't need to bundle NodeJS!
--- inspired by jupyter notebooks ---
Possible Solutions
use NodeJS as backend.
use python and combine it with Flask or Django as backend. (I think this would be the most lightweight solution)
use PHP as backend. (the best, personal opinion)
use ASP.NET/Blazor as backend. (as mentioned in the comments; but doesn't seem to be a lightweight solution)
or use any language that you can create a web application with that!
make a runApp.bat or runApp.sh to simply run your server and open the browser automatically.

What if we don't host our silverlight Application when we first Create it?

As we all know very well..
whenever we create application inside silverlight it is asking us for hosting it
by dialogue box at given below.
My question is what if i unchecked the check box[Host the silverlight application in a new web site].
Means what kind of problem we have to face later if I don't host our Silverlight Application in any of the option given by dialogue box.
Basically it is not a problem at all. You can add a website at any time later.
In the project settings of a website there is a Silverlight tab. Under that you will find the option to add Silverlight projects to the website. This will setup the links to generate the XAP in ClientBin as well as giving you the option to create test pages for each Silverlight app added. The test pages will give you the sample JS you need to host your Xap later.
You will have to eventually host your application somewhere otherwise it will stay on your local harddrive and hardly reach any clients. So if you have an existing web site you could simply copy-paste the necessary javascript to this site later in order to embed your Silverlight application. In this case you can uncheck this checkbox.

TestPage.aspx in silverlight

I am a beginner in silverlight. I want to know what is TestPage.aspx and TestPage.html in silverlight. Actually i have google it but din't get enough information. Can any one give me answer??
TestPage.aspx and TestPage.html are the pages which will host your Silverlight content. As you might know, Silverlight is just a project (not a web application) and needs a page that can host it.
These pages are created by default and help you to test your XAML content during your development, which you can later remove from your project.
TestPage.html is dynamically generated by the Silverlight application as part of the Debug process. If you take a look at the Debug tab for the application properties you will see an option to Dynamically generate a test page. If this is selected then you TestPage.html is created in the /Bin/Debug folder of your Silverlight application.
A better solution is to create a web application in the same solution as your Silverlight application then in the properties for the web application go to the Silverlight Applications tab and add your existing Silverlight app to the web project. Also make sure that the Silverlight checkbox is ticked in the Debuggers section of the Web tab of your web application.

Cross-site images in Silverlight

Is it possible to load in an image from another domain using JavaScript, and then pass the image to a Silverlight control on my page?
The only workaround I'm familiar with for this, since it's a security issue, is to set up a web service on a server you have control over, request the image from this web service from your Silverlight application, then have the service grab the image from the other server and return it to the client.
Loading cross-domain images should not be an issue in Silverlight, at least if you are using the normal Image control. I just tested this with a really simple application containing only an Image control with the Source property set to an image from google images.
Are you loading your images in some funky way with the WebClient? Cross-scheme and cross-zone access is restricted for the Image class, so you would not be able to load an image (on any domain) over SSL if you loaded your XAP over regular HTTP.
The MSDN page on Silverlight URL Access Restrictions gives you a good overview of what you can and cannot do with Image, MediaElement, WebClient, and streaming video.

Resources