I'm developing an application using cefSharp
, all is good now i need to maintain history for all browser tabs opened and closed by user and providing a option for opening closed tabs.
Is there a way to store Chromium Web Browser object into memory or database and retrieve it from there. I've used below code to store objects into database
var objBrowserTest = (ChromiumWebBrowser)browserControl;
MemoryStream memStream = new MemoryStream();
StreamWriter sw = new StreamWriter(memStream);
sw.Write(objBrowserTest);
string sql = @"
INSERT INTO tblBrowserObj(cromObj)
VALUES(@VarBinary);
SELECT @@identity";
string connectionstring;
connectionstring = ConfigurationManager.ConnectionStrings[0].ConnectionString;
SqlConnection objConn = new SqlConnection(connectionstring);
if (objConn.State == ConnectionState.Open)
{
objConn.Close();
}
objConn.Open();
SqlCommand sqlCmd = new SqlCommand(sql, objConn);
sqlCmd.Parameters.Add("@VarBinary", SqlDbType.VarBinary, Int32.MaxValue);
sqlCmd.Parameters["@VarBinary"].Value = memStream.GetBuffer();
string strID = sqlCmd.ExecuteScalar().ToString();
if (objConn.State == ConnectionState.Open)
{
objConn.Close();
}
Table structure
CREATE TABLE [dbo].[tblBrowserObj](
[id] [int] IDENTITY(1,1) NOT NULL,
[cromObj] [varbinary](max) NULL
) ON [PRIMARY]
My problem is that the memStream.GetBuffer()
always shows byte[0]
.
Can any one tell me how can i store and retrieve Chromium Web Browser object from memory or database, or is there another way to do this type of stuff.