1

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

Jatin Gadhiya
  • 1,955
  • 5
  • 23
  • 42
  • Is the solution required to work for all browsers, or are you restricting yourself to a specific one? – BobbyJ Oct 09 '15 at 17:12
  • I want to open default browser. not an issue... but make sure your solution will open browser window not a new tab from LS desktopclient... let me know for future detail if you want – Jatin Gadhiya Oct 09 '15 at 17:19

1 Answers1

0

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.

Community
  • 1
  • 1
BobbyJ
  • 371
  • 2
  • 9