How to get the URL query string of your Microsoft Ligthswitch application?

Sometimes you want external websites to modify your application internally and the obvious solution is through your URL query string.  To extract the URL query string you need only to put a code at the Application_Initialize method.

Below is my example.  I modified my URL link to include a query string called “Parameter” and equate to a value “Main”.

First is to open your Application Class and add the two imports:

Imports Microsoft.LightSwitch.Threading
Imports Microsoft.LightSwitch.ApplicationInfrastructure.Utilities.Internal

Then modify the Application_Initialize method:

        Public Branch As String

        Private Sub Application_Initialize()
            Dispatchers.Main.Invoke(Sub()
                                        Dim DefaultBranch As String = Nothing
                                        QueryStringHelper.TryGetValue("Parameter", DefaultBranch)
                                        If DefaultBranch IsNot Nothing Then
                                            Branch = DefaultBranch
                                        End If
                                    End Sub)
        End Sub

The source code above includes a public Branch property to which you save your query string result so that you can use it throughout your application via Application class.  Notice that you only need a simple QueryStringHelper function to extract the external URL query strings called “Parameter”.  Very simple.

Thats it!  If you find this blog helpful, you can make the donation by clicking the Paypal button below.

Advertisements
About

Software developer living in the Philippines.

Posted in Lightswitch

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Author

Harold Glenn P. Minerva
Software Developer / Tech Enthusiast
Living in the Philippines

View Harold Glenn Minerva's profile on LinkedIn

Instagram

Software Engineer - Seasonal and Range Trading Software. Magenta Trader is a powerful stock market visualization software that increases your probability of trading success.

Software Architect and Founder - Easyfis.com is a multi-tenant cloud-based Software-as-a-Service (SaaS) business app that caters to micro, small and medium trading businesses.

CTO and Co-Founder - We give your company the leverage by providing innovative software solutions products such as Point-of-Sales (POS), Financial Information System (FMIS), Payroll and DTR (HRIS), and many more.

%d bloggers like this: