Open a Website from C#

It is often a requirement to open the default web browser and browse to a specific Url from a Windows Forms, WPF or even Console application. The easiest method I’ve discovered is to make use of the System.Diagnostics.Process class:

 using  System;
 using  System.Collections.Generic;
 using  System.Text;
 using  System.Diagnostics;
 
 namespace  OpenDefaultBrowser
 {
     class  Program 
     {
         static  void  Main(string [] args)
         {
             Process .Start("http://softwarebydefault.com" );
         }
     }
 }
 

In most scenarios the code snippet listed above works without a problem. The only issue I foresee being in an environment where the user account used to execute your application not having sufficient permissions to execute the default browser application.

For more information see MSDN Process Class

Advertisement

0 Responses to “Open a Website from C#”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s




Dewald Esterhuizen

Blog Stats

  • 836,220 hits

Enter your email address to follow and receive notifications of new posts by email.

Join 228 other subscribers

Archives

Twitter feed


%d bloggers like this: