locked
Lightswitch App running as web app - startup parameters RRS feed

  • Question

  • hi,

    I would like to be able to call the web app and pass in 2 parameters at startup, how do you do that ?

    can i supply initparams in default.htm? if i do how do i read those from the startup screen?

    Thanks

    Mr P

    Monday, January 20, 2014 7:07 PM

Answers

  • partial void Application_Initialize() { string s; string[] querySegments = null; Dispatchers.Main.Invoke(() => { s = HtmlPage.Document.DocumentUri.Query; querySegments = s.Split('&'); }); string propertyId = null; string tenantName = null; Dictionary<string, string> queryParameters = new Dictionary<string, string>(); foreach (string segment in querySegments) { string[] parts = segment.Split('='); if (parts.Length > 0) { string key = parts[0].Trim(new char[] { '?', ' ' }); string val = parts[1].Trim(); queryParameters.Add(key, val); } } if (queryParameters.TryGetValue("ID", out Id)) this.Id = Id; if (queryParameters.TryGetValue("Name", out Name)) this.Name = Name; } public string Id { get; private set; } public string Name { get; private set; } }

    did some digging, this seems to work

    so now i can set up url with default.htm?ID=123&Name=MrP

    and use those parameter in the app



    • Edited by mrP Monday, January 20, 2014 8:47 PM spelling
    • Marked as answer by Angie Xu Monday, January 27, 2014 7:54 AM
    Monday, January 20, 2014 8:46 PM