c# - Using CefSharp with Owin TestServer -
due potential firewall limitations , need have many instances of app cannot competing ports, use microsoft.owin.testing.testserver class create in-memory web server serve requests embedded cefsharp browser (either wpf or winforms fine).
i can create testserver no issues. how can configure cefsharp webbrowser control use test server rather using standard os network stack?
if forming own requests, either use httpclient provided testserver or create new httpclient using testserver's handler. there equivalent functionality in cefsharp webbrowser?
you can intercept requests , fulfill them yourself. if implement iresourcehandlerfactory subsequently iresourcehandler (just return new instance of custom iresourcehandler in iresourcehandlerfactory.getresourcehandler)
https://github.com/cefsharp/cefsharp/blob/cefsharp/45/cefsharp/iresourcehandlerfactory.cs#l22
a new instance of custom resourcehandler instantiated every request. it's relatively simple process request in async fashion, invoke request in processrequestasync, when it's complete fill local stream data execute callback.continue(), return stream , populate response in getresponse. wrap callback in using statement wraps managed resource , should explicitly disposed of.
you can see basic example @ https://github.com/cefsharp/cefsharp/blob/cefsharp/45/cefsharp.example/cefsharpschemehandler.cs#l92 (doesn't make network requests, principal same though)
Comments
Post a Comment