简体   繁体   中英

Closing an aspx page after redirect to a clickonce application

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.

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.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM