0

我正在使用缓存清单使 Web 应用程序可以离线访问。在我添加连接到 SQL Server 数据库的功能之前,一切正常(使用存储在代码中而不是 web.config 中的连接字符串)。该页面是一个简单的空测试页面,没有图像或其他资源。不知何故,它是阻止它工作的数据库连接 - 它曾经工作过(即使有数据库连接),然后就停止了......

代码(仅 page_load...页面中没有其他内容)页面名为“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();
}

知道为什么会这样吗?

4

1 回答 1

0

如果您像这样动态生成清单,那么您需要确保304 Not Modified在文件实际上没有更改时以 a 响应(请参阅步骤 7),否则(在步骤 24)将在浏览器时重新下载整个缓存对清单文件进行第二次请求,以确认在实例化缓存时它尚未更新。在清单 URL 上设置过期标头也很重要,这样浏览器就不会缓存清单本身。

于 2013-06-11T10:38:50.817 回答