views:

611

answers:

2

I have code in code behind portion of my aspx page. On a button click a function gets called so that a clickonce application loads. Originally I was doing all of this in javascript. The js set the window.location to the url of my clickonce application, and close through a timeout. This worked fine until I installed the application on another server. IE does not allow the clickonce application to get loaded through client side script. I am now forced to do a redirect to the url of the clickonce application. The problem that I'm encountering now is not having access to be able to close the window where the redirect was initiated from. The redirect fires first before any js could run. I basically need a way to slow down the redirect so that i can run my js.

+1  A: 

You could redirect to a page that will have the JavaScript you had before - to close the window and redirect to the clickonce application. You could pass the URL of the application to this page in the query string. The page could be plain html.

John Saunders
I'm not sure if i was clear in my question. I have to do a server side redirect to a url that is an application. Using javascript to open the url is not an option. Once I do a server side redirect to a url of the appliation, I no longer have control over the page so that I can close it.
I meant have the server-side code render a page with a JavaScript redirect to the URL computed by the server. This is how SAML logins work - a page is rendered that does a POST from the JavaScript to a URL. You could do a GET.
John Saunders
Either I'm not understanding your solution, or I'm having a hard time explaining my problem. The problem is that I can't do any client script to get to the url of the application. If I attempt to access the page through js, the browser blocks it because of security issues.
Sorry; I forgot that part. If this is a "cross-domain" issue, then let the server redirec, but to a .htm page in the domain where the clickonce application is located. That page, being in the correct domain, shuold be able to set window.location to the clickonce URL, then close on the timer.
John Saunders
A: 

you could do something like this. I am using jquery but you dont have too..

webmethod = GetUrlToApplication, is basically returning path.

<script type="text/javascript">
    $(document).ready(function() {
        $.ajax({
            type: "POST",
            url: "Default.aspx/GetUrlToApplication",
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: ajaxSucceededFn, 
            error: errorFn                  
        });
    });

     function errorFn ()  
     {   
        alert('Error:-Unable to launch Application.');  
     }
     function ajaxSucceededFn (result)  
     {
         window.location = result;
         setTimeout(function() { window.open('', '_self', ''); window.close(); }, 1000);
     }

</script>
Pramod