namespace Skype.FileTransfer.Controls.Utils { using CefSharp; using CefSharp.Handler; using Controls; public class RequestHandler : DefaultRequestHandler { private string _requestedUrl = ""; private bool _isCredentialsPrompted = false; public override void OnResourceLoadComplete(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength) { var result = _requestedUrl.Contains(request.Url); base.OnResourceLoadComplete(browserControl, browser, frame, request, response, status, receivedContentLength); } public override CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { if (_isCredentialsPrompted) { if (request.Url.EndsWith("errorPage.html")) { // Here I need to refresh or delete the cache string url = this._requestedUrl; browserControl.Load(url); } } else { this._requestedUrl = request.Url; } return base.OnBeforeResourceLoad(browserControl, browser, frame, request, callback); } public override bool GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) { bool handled = false; _isCredentialsPrompted = true; // Instantiate the dialog box AuthBox dlg = new AuthBox(); // create new dialog with username and password field. // Open the dialog box modally dlg.ShowDialog(); if (dlg.DialogResult) { // The user did not cancel out of the dialog. Retrieve the username and password. callback.Continue(dlg.Username, dlg.Password); handled = true; } else { var filelocator = new FileLocator(); string url = filelocator.GetFilePath("errorPage.html"); browserControl.Load(url); } return handled; } } }