0

I am using a cache manifest to make a web application accessible offline. It all works fine until I add the functionality which connects to the SQL Server database (using a connection string stored in code behind not in web.config). The page is a simple empty testing page with no images or other resources. Somehow it is the database connection that is stopping it from working - it used to work before (even with database connectivity) and then just stopped...

CODE (page_load only...nothing else in page) page called 'tryit2.aspx'

protected void Page_Load(object sender, EventArgs e)
    {
            //open connections
            oConn = new SqlConnection();
            oConn.ConnectionString = _connectionString;
            oConn.Open();

            ////----FETCH SUBCAT PRODS FROM DB
            _currentDT = new DataTable();

            SqlDataReader sqlDR2 = this.executeSQLcommand_returnDataReader(oConn, loadMenu, true, null);
            _currentDT = new DataTable();
            _currentDT.Load(sqlDR2);
            sqlDR2.Dispose();

            //dynamically create the cache manifest file
            string appPath = Request.PhysicalApplicationPath;
            string filePath = appPath + "cache.manifest";
            StreamWriter w;
            w = File.CreateText(filePath);

            w.WriteLine("CACHE MANIFEST");
            w.WriteLine("CACHE:");

            w.WriteLine("tryit2.aspx");

            w.WriteLine("NETWORK:");
            w.WriteLine("*");

            //closing the streamwriter
            w.Flush();
            w.Close();
}

Any idea why that might be please?

JeanPaul Galea
  • 113
  • 3
  • 11

1 Answers1

0

If you generate the manifest dynamically like this then you need to be sure to respond with a 304 Not Modified if the file hasn't in fact changed (see step 7), otherwise (at step 24) the entire cache will be re-downloaded when the browser makes a second request for the manifest file to confirm it hasn't been updated while the cache was being instantiated. It is also important to set expiry headers on the manifest URL so that the browser never caches the manifest itself.

robertc
  • 74,533
  • 18
  • 193
  • 177
  • thanks Robert...so why does the database connectivity cause the failure then? here I am not updating the cache manifest but creating it from scratch where it does not yet exist...if it is created, then wouldn't it simply load the cached version when the page is accessed? – JeanPaul Galea Jun 11 '13 at 11:13
  • I also tried defining the cache manifest statically by typing in the manifest entries myself and still it does not work when I have the database connectivity – JeanPaul Galea Jun 11 '13 at 11:16
  • @JeanPaulGalea Check the request headers – robertc Jun 11 '13 at 12:05