Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening a URL containing a query string

I need to be able to open a link in a browser from a C# application. Normally, I would use a code like this to open the link:

Process.Start(new ProcessStartInfo("explorer.exe", @"http://www.google.com"));

Unfortunately, that only succeeds in opening explorer and not a browser when the URL contains a query string such as: http://www.google.com/search?q=stackoverflow

How can I open URLs with query strings?

Edit Notes: I am using Windows 8 with non-IE default browsers. I am seeing the same error with 'Class Not Registered' when trying to use just Process.Start as described here: Process.Start(url) broken on Windows 8/Chrome - are there alternatives?

like image 967
cvocvo Avatar asked Sep 20 '25 00:09

cvocvo


1 Answers

Finally found a solution -- kind of impressed I didn't try this to begin with after writing batch files years ago this was common.

Process.Start(new ProcessStartInfo("explorer.exe", "\"" + @"http://www.google.com/search?q=stackoverflow" + "\""));

Just adding quotes around it seems to work fine.

like image 93
cvocvo Avatar answered Sep 21 '25 14:09

cvocvo