Skip to content

Commit a889c47

Browse files
committed
WinForms Example - Use google.com as search engine when invalid url entered in address
If Uri.IsWellFormedUriString is false then we'll load using https://www.google.com/search?q=
1 parent 1eb8967 commit a889c47

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

CefSharp.WinForms.Example/BrowserTabUserControl.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Collections.Generic;
77
using System.Linq;
8+
using System.Net;
89
using System.Runtime.InteropServices;
910
using System.Threading.Tasks;
1011
using System.Windows.Forms;
@@ -384,6 +385,13 @@ private void LoadUrl(string url)
384385
{
385386
Browser.Load(url);
386387
}
388+
else
389+
{
390+
var searchUrl = "https://www.google.com/search?q=" + WebUtility.HtmlEncode(url);
391+
392+
Browser.Load(searchUrl);
393+
}
394+
387395
}
388396

389397
public async void CopySourceToClipBoardAsync()

0 commit comments

Comments
 (0)