1

For example, the user has multiple browsers: Chrome, Firefox, and Safari, and the user's default browser is Chrome. How can I make it so that when the code opens the user a link, it will use Safari instead of his default browser, which is Chrome? Is that even possible? Thanks :)

1
  • 2
    you can use Process.Start() and you need to specify the browser name in it which you want to open, For Safari use its exe name like Process.Start("safari.exe","http://www.stackoverflow.com") Commented Jul 25, 2015 at 12:38

2 Answers 2

4

Try this:

System.Diagnostics.Process.Start("Chrome.exe", "http://www.stackoverflow.com");//or firefox.exe 

You might have exceptions if the browser is not configured correctly. So it is better to catch the exception like this:

try { System.Diagnostics.Process.Start("Chrome.exe", "http://www.stackoverflow.com");//or firefox.exe } catch(System.ComponentModel.Win32Exception noBrowser) { if (noBrowser.ErrorCode == -2147467259) MessageBox.Show(noBrowser.Message); } catch (System.Exception other) { MessageBox.Show(other.Message); } 
Sign up to request clarification or add additional context in comments.

Comments

0

When application is going to start or Global.asax event, we should handle this scenario than only we can redirect to request to any client browser. This trick should not even try with page events.

Use the nameSpace and add the code in global page : process.Start()

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.