WebCoreCreateWebSession Method (WebPreferences)Awesomium.NET 1.7.6Awesomium.NET
Creates an in-memory WebSession which will be used to store all user-data (such as cookies, cache, certificates, local databases, etc).

Namespace: Awesomium.Core
Assembly: Awesomium.Core (in Awesomium.Core.dll) Version: 1.7.6.0
Syntax

public static WebSession CreateWebSession(
	WebPreferences preferences
)

Parameters

preferences
Type: Awesomium.CoreWebPreferences
A WebPreferences instance indicating session specific preferences.

Return Value

Type: WebSession
Returns a new WebSession instance that you can associate with any number of IWebView instances.
Remarks

The returned WebSession instance can be used when you create a IWebView instance, by either specifying it as the session parameter in CreateWebView(Int32, Int32, WebSession), or by assigning it to the WebSession property of technology specific WebControls, when you instantiate them.

IWebView instances that share the same WebSession, share the same cookies, cache, certificates, local databases as well as the same preferences (see WebPreferences).

WebSession is a disposable object. You can dispose WebSession instances that are no longer associated with a view. If you forget to do this, all WebSession instances maintained by the WebCore, are disposed at Shutdown.

Caution note Caution
A session cannot not be destroyed until all IWebView instances associated with it have been destroyed, and all download operations controlled by it are either complete or canceled. Attempting to dispose a WebSession instance that is still associated with views or active download operations, will throw an exception in Awesomium.NET.
For details on how to use a WebSession, read the documentation of WebSession, or the following article: Using Web-Sessions
Examples

using ( WebSession session = WebCore.CreateWebSession( new WebPreferences() { CustomCSS = "::-webkit-scrollbar { visibility: hidden; }" } ) )
{
    using ( WebView view = WebCore.CreateWebView( 1280, 960, session ) )
    {
        view.LoadURL( new Uri( "http://www.awesomium.com" ) );
        view.LoadingFrameComplete += ( s, e ) =>
        {
            if ( !e.IsMainFrame )
                return;

            BitmapSurface surface = (BitmapSurface)view.Surface;
            surface.SaveToPNG( "result.png", true );
        };

        if ( WebCore.UpdateState == WebCoreUpdateState.NotUpdating )
            WebCore.Run();
    }
}
See Also

Reference