Have you ever tried to pass parameters on the query string to one of your "click once" web deployed WinForms application? If you have, you’ll likely end up with an empty query string, even after following the directions on the following MSDN pages:
I spent countless hours debugging and researching this issue, finding no answers anywhere and finding several people posting questions in forums about this issue… all with no resolution!
Here are the general directions from MSDN:
1. Mark your WinForms application as being able to receive query string parameters (right-click project/properties/publish/options, check "Allow URL parameters to be passed to application").
2. In your code, you access the query string as so:
I tried a million times trying to get my parameters to pass through to my application. Here’s how I was testing it:
1. Deploy your WinForms application (right-click project/publish, fill in path info, click next, etc… until published).
2. Browser opens up to something like: http://localhost/myapp/publish.htm
3. Click on address and add "?test=whatever" so the full URL looks like: http://localhost/myapp/publish.htm?test=whatever and hit enter to reload publish.htm with those paramters.
4. Click the "run" button on the publish page.
5. App opens up, but the query string is blank: (new Uri(AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[x])).Query
As it turns out, my code was right all along. The trick is in the URL. Forget the publish.htm page. It can’t do it. What you need for the URL is this:
That’s the trick to it. This bypasses the publish page altogether and launches the application immediately AND your query string WILL have the proper data in it!.