Launching app from website, retrieving query string info

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • z1freeride
    New Member
    • Feb 2009
    • 36

    Launching app from website, retrieving query string info

    I'm trying to launch my C# app from a website and send it some query parameters like so: http://www.test.com/app.application?...t&param2=test2

    According to: http://msdn.microsoft.com/en-us/library/ms172242.aspx, I need to have this line of code:

    Code:
    string queryString = ApplicationDeployment.CurrentDeployment.ActivationUri.Query;
    But my app crashes. It says that (after narrowing it down) ActivationUri reference is not set to an instance of an object.

    Do you know why ActivationUri would be null?

    Thank you.
  • z1freeride
    New Member
    • Feb 2009
    • 36

    #2
    Hm, according to this: http://www.devnewsgroups.net/group/m...opic62067.aspx, my application has to be set as "online only" in order to access the query parameters. Right now, I have it set as availalbe offline as well (launchable from Start menu).

    Is this correct?

    Comment

    • tlhintoq
      Recognized Expert Specialist
      • Mar 2008
      • 3532

      #3
      Never code based on everything being right. Code based on the idea that anything that can go wrong, will go wrong.
      In the one line of code you supplied (which isn't much to go on) there is a presumption that the right side of the statement is going to return a string. If it doesn't, then it breaks.

      Do you know why ActivationUri would be null?
      If you set your variable equal to *something* before using it you eliminate that being an issue.
      Code:
      string querystring = string.empty;
      then check to see if you have a value to use.
      Code:
      if ((!string.IsEmptyOrNull(ApplicationDeployment.CurrentDeployment.ActivationUri.Query))
      {
      // Then do your code here if you actually have a value
      }
      else
      {
      // Query is null : Now what?
      }

      Comment

      • z1freeride
        New Member
        • Feb 2009
        • 36

        #4
        Thanks for the tips tlhintoq. You've helped me out a lot.

        The problem is that I need to use:

        Code:
        System.Deployment.Application.ApplicationDeployment.CurrentDeployment.ActivationUri.Query
        but it is always NULL. It should contain parameters for me to use when I launched the app from a website. I just don't understand why it is NULL.

        Comment

        • z1freeride
          New Member
          • Feb 2009
          • 36

          #5
          So I found the solution. I need to check the option to allow parameters to be passed under the Publish settings -> Options.

          Thanks for your suggestions.

          Comment

          Working...