Deploy ClickOnce Application Using HttpWebRequest

I am trying to start a ClickOnce application using C # code with the HttpWebRequest class. The application can be deployed using IE. But when doing deployment with my code, it seems that only the .application file is being downloaded to the client.

My code looks like this.

        HttpWebRequest getRequest = (HttpWebRequest)WebRequest.Create("http://localhost/test/test.application");
        getRequest.Method = "GET";
        getRequest.Timeout = 500000;                   //default is 100 seconds  

        HttpWebResponse getResponse = (HttpWebResponse)getRequest.GetResponse();
        string loginUrl = getResponse.ResponseUri.AbsoluteUri;
        StreamReader responseReader = new StreamReader(getResponse.GetResponseStream());
        string responseData = responseReader.ReadToEnd();
        responseReader.Close();

      

Is there something I am doing wrong with my code?

Thank! - Bruce

+1


source to share


1 answer


I believe there is something special that IE does when it sees the .application file. That's why ClickOnce deployment didn't work with FireFox until .NET 3.5 SP1 added a handler for it. What you see will be the correct behavior - your application is just pulling the file as a stream of bytes - it doesn't know what to do with it.

If you want to run your application programmatically, I would suggest instead:

System.Diagnostics.Process.Start("http://localhost/test/test.application");

      



Update

There's a bit more information about the whole ClickOnce / FireFox operation here . Apparently there is a MIME type handler set for IE, which recognizes the application type / -ms-application and runs the ClickOnce installer file. It might be worth checking out some of the older FireFox add-ons that included this prior to .NET 3.5 SP1 and see what they did to run the .application file programmatically.

+2


source







All Articles