We wrote a web application which needs to launch a Microsoft ClickOnce application, while at the same time redirect the user to a new page. The basic flow of the program is this:
- User navigates to web application
- Unique GUID for transaction ID is generated for the ClickOnce application to use
- The user clicks the launch link and the GUID is passed to the ClickOnce application as a URL parameter
- a) the ClickOnce app launches
- b) the user is taken to a “wait for the results screen” while the ClickOnce application is working
- The ClickOnce application takes a measurement with a USB device
- The ClickOnce application calls a web service to store the measurement, using the passed-in GUID as the key
- The ClickOnce application closes itself
- The “wait for results screen” meta-refreshes until it sees the results in the underlying database
- The “wait for results screen” redirects the user back to the measurements list page
The problem we were facing had to do with using a JavaScript window.open() function to launch the “.application” ClickOnce URL. Basically, when we did this it opened a new browser window, which immediately closed without launching the ClickOnce application.
Solution:
Use the JavaScript setTimeout() function.
<html>
<head>
<script type="text/javascript">
function LaunchApp() {
setTimeout("location.replace('waitPage.htm')", 2000);
}
</head>
<body>
<!-- the id below is generated by the code behind -->
<a onclick="javascript:LaunchApp();"
href="MyClickOnceApp.application?id=30F0D180-2CFC-3A80-F90922B0B31B656A">
Click here to launch application</a>
</body>
</html>


0 comments:
Post a Comment