简体   繁体   中英

How to open browser window in lightswitch application?

I want to open browser window instead of new tab in current/default browser.

I am using this code in desktop client on screen command button click event.

            Microsoft.LightSwitch.Threading.Dispatchers.Main.BeginInvoke(() =>
            { 
                if (AutomationFactory.IsAvailable)
                {
                    dynamic shell = AutomationFactory.CreateObject("Shell.Application");

                    shell.ShellExecute("http://localhost:55722/Home/Index");
                }
                else if (!System.Windows.Application.Current.IsRunningOutOfBrowser)
                {
                    HtmlPage.Window.Navigate(new Uri("http://localhost:55722/Home/Index"), "_blank");
                }
                else
                {
                    throw new InvalidOperationException();
                }
            });

This code is opening my page in current/opened browser tab.

Can you please advice how to open browser window in desktop client on screen command button click event.

Your answer will appreciable! :)

Thanks,

Jatin

I tried this with IE and it opens a new window each time:

dynamic shell = AutomationFactory.CreateObject("WScript.Shell");
shell.Run("iexplore.exe", 1, true);

Other browsers may work, but some may require command line arguments to open a new window every time. See Open a browser window as a pop under in C# for a Chrome example.

To detect the default browser, you could read from the appropriate location in the registry, as shown in Access registry from Silverlight OOB .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM