Start WPF application from link in browser? - wpf

We have a requirement to start a WPF application with specific parameters from a link in a browser.
We are wondering if this is possible?
As an alternative could we embed the web application in a WPF browser control, and read the values out of the html web page?

Several possibilities :
if you control the browser (i.e. if you are in an intranet scenario, and have the opportunity to deploy applications), you can :
create an activex or plugin that runs the application
register a new uri scheme to interpret the url of kind "yourapplication://yourarguments"
(complex): deploy a listening app ran under the user session, and from the webapplication, ask this listening app to run the target application
reduce the security of the browser (not recommended)
if you don't control the browser:
create a clickonce application... this involves a setup, but which does not require admin privilege
Moving to Silverlight also might be an option, depending on your needs. SilverLigth V5 (still in beta) notably adds the ability for an admin to control the rights of the application via a GPO
Note: My feelings is the later option (Silverlight) is far more preferable because it's a lot more cleaner and less security hole factor. However, it can only be done if your requirements fits into the SL features

It is not possible to call client app from a browser, previously it was possible from activex controls but for that you need to have a signed library, in wpf you can make browser based application but you cant embed your web app in it.
So partially you are correct if you used wpf app you will be able to launch application on client side but with browser it seems difficult until unless you make activex control
but still i am not 100% sure that with activex control you will be able to launch the app or not

Related

Best practice for OAuth/OIDC SSO with a WinForms app?

We are adding modern authentication (OAuth/OIDC) to an application that currently uses Windows integrated authentation for single sign on. The user signs into Windows workstation and those credentials can be used by many applications with authentication happening transparently over Kerberos.
Our app is a dot net web services based application and we have a client for users with browsers and a desktop client in WinForms. The browser scenario is no issue as the identity provider stores information in the browser that can be reused across applications in a similar way to WIA (IWA), but we are unsure the best way to handle the WinForms desktop application case. Currently the WinForms application opens a browser window to authenticate using the typical browser based method. The details from the identity provider are passed through the browser back to the WinForms app using a redirect and a custom protocol based URL.
This all works fine, but the user experience is not super tight and, for the case where the user is already logged in, requires them to press a button in the browser window as current Chromium based browsers seem unwilling to do a redirect without a recent user interaction.
Is there a better way?
The standard options according to RFC8252 are as you describe:
Log in via the system browser
Use either a loopback or private scheme based URL
I have a few blog posts about this and it is a tricky flow. The posts link to code examples you can run that explore the UX a little. You may find that a loopback URL avoids the need for a button click, though personally I think private scheme based URLs are cleaner.
There are UX things you can do, such as an interstitial web page to better control what happens in the disconnected browser. I have seen companies redirect to their own website after desktop logins, to make the UX better.
In the longer term I expect this to be replaced with API Driven OAuth Flows so that you never need to leave the app. For now you may have to live with some UX linitations, but it is the right flow from a security viewpoint.

Is Metro a good fit for apps that access the File System?

I understand that Metro limits the access an app has to the user's computer. Can anybody verify this, as I am considering creating an email client that will work with at least yahoo/at&t.net and gmail. Will I be able to access a user's email (assuming they provide their username and password, of course) with a Metro style app, or will I need to stick with creating an "old-fashioned" Desktop app for this scenario?
Metro applications can access the users Document Library, Picture Library, Video Library and Music Library without user intervention if the developer adds those capabilities to the Package.appxmanifest (double-click on it in Visual Studio and go to the Capabilities tab).
Even without these capabilities the app can read and write in its own local folders. And even with out these capabilities the app can prompt the user to open a file anywhere on disk using the FileOpenPicker. So yes, absolutely Metro can be used for an e-mail client.
For a sample of using FileOpenPicker (i.e. to add an attachment to your e-mail message) see:
http://code.msdn.microsoft.com/windowsapps/File-picker-sample-9f294cba
Metro can easily be used to create email clients. For something like this, you would be syncing data between the mail-server and the client.
Metro apps have limited access to the filesystem. But they can access Application Data Storage and isolatedStorage which can be used to store data pertaining to the application offline. This helper library helps store structured data in isolated storage, and might suit your needs.
For your scenario, a metro application would be a very good fit. However, the reach of metro applications will be decided by how well Windows 8 does after launch.

How to have a SharePoint action invoke a feature in a WinForms application launched by Click-Once?

We have a SharePoint site that our users have open all the time (type of dashboard for the business). We have a WinForms application that listens on a specific port for when the user clicks a web part on the SharePoint site, we take the JSON in the WinForms, parse the request and launch a feature in the WinForms. Essentially allowing a web site to launch a feature in a running WinForms app on the same client machine.
This worked great when we were running in XP. When we moved to Windows 7 (with elevated UAC), this feature stopped working. Since we launch the WinForms app via ClickOnce, and ClickOnce apps can't be Run As Administrator, our current code won't work.
We can't make the ClickOnce app Run As Administrator for all the reasons you see here on StackOverflow.
So my question is: how can we invoke a feature in a ClickOnce deployed WinForms app when a user clicks on something in SharePoint site? It is super easy to get the WinForms app to call a Sharepoint web service but I need to go the otherway.
You can invoke a ClickOnce application by calling the deployment manifest URL. If you want to be able to call the app and have it do something specific, call the deployment manifest URL and pass query parameters to it, then have the application handle the query parameters.
This article shows you how to handle query parameters with ClickOnce applications.

Coded UI Test builder fails to recognize controls when XAP is hosted at different domain

The Coded UI Test Builder fails to recognize Silverlight controls when the application (XAP) source is a different domain
I placed XAP at two different locations
http:\Domain1\MyApp\MyApp.XAP
http:\Domain2\MyApp\MyApp.XAP
My WebPage is at http:\Domain1\HomePage.html
If the Silverlight object's source is set to 1st one (same domain) it works fine and CUIT builder recognizes, records and playbacks properly. But, when I set the source to 2nd one (i.e. different domain), the CUIT builder fails to recognize Silverlight app.
The application itself work fine when hosted at Domain1 or Domain2. The recording is also successful when web page at DomainX refers to app at same DomainX. It fails to record when web page at DomainX refers to the same app at DomainY. What do I need to make it work?
Thanks
PS: Please note that the Silverlight application itself works fine no matter from which domain I am using - I have appropriate crossdomain policy file available and enableHtmlAccess set to true.
I have also verified presence of automation helper dll in XAP at both places (infact same XAP has been placed
I had logged this bug on MSDN connect - Coded UI Test builder fails to recognize Silverlight controls in cross domain XAP
This has been marked as "Won't Fix":
"We have investigated this scenario and determined that cross-domain XAPs cannot be supported by Coded UI Test. We use CreateFromXAML apis to enable the UI Testing component for Silverlight and
this API is failing for cross domain XAPs. Unfortunately, we have not been able to identify a workaround either. Closing the bug as Won't fix"

Intercommunication between two .Net Applications using WCF service

I have a WPF application. On the same machine I have a console application.From this console application i want to see if user has successfully logged in and a particular page is open in WPF application. If this is the case then i want to show a popup in WPF application.
To implement this I Thought of using WCF services. I have got 2 options. Create a seperate WCF service and run it as soon as WPF application runs and then ask the client application to communicate.
Second option is to host the WCF service inside the WPF application and run it when WPF application starts.
I am not able to decide on which way to choose. If anyone of u has implemented this kind of setup before,please share your ideas.
Because you want to see if a page is open in the WPF application, I'd suggest hosting the WCF service in the WPF application (i.e., using the ServicHost class). Then have the console application consume the service to determine the page status as per your requirement.
Also, use the NetNamedPipeBinding (http://msdn.microsoft.com/en-us/library/system.servicemodel.netnamedpipebinding.aspx).

Resources