This code snippet is related to open site/URL from the windows application.
In some cases, we need to open the website from the windows application. In that case, we need to check the URI.
URI can contain spaces as well as some special characters. SO that we need to convert that characters in such way we can able to open the site.
Like if there is a space in the URI, it will be converted by %20.
If you want to open site from your windows application, you can use following code.
First of all, It will check the URI.
Secondly,It will convert the spaces and special characters in appropriate form so that we can open the website.
Then, Open the URI, if it is well formed string.
// Create new URI object by passing the uri string
Uri uriString = new Uri("http://www.google.com");
// Sometimes there are spaces and special characters in the URI.
// Following code replace the spaces as per the Http rules
string absUriString = uriString.AbsoluteUri.ToString();
// Check the URI is wellformed string or not if(Uri.IsWellFormedUriString(uriString.AbsoluteUri.ToString(),UriKind.Absolute))
//Start the process if URI is correct. It will open the site in default