| | |
SQLCacheDependency not notifying
![]() |
•
•
Join Date: Feb 2009
Posts: 8
Reputation:
Solved Threads: 0
Hi everybody
I have coded a LINQ SiteMapProvider for my ASP.NET site. The site pages info is stored in a MSSQL database.
When I make changes to the SitePAges table, the SiteMap does not reset. Here is my code If i understand correctly, the OnSiteMapChanged sub is supposed to run as soon as the tableset becomes invalidated, which somehow never occurs. I put dependenct.start and dependency.stop in my global.asax file in app_start and app_end respectively
My debugging shows that the "Insert" code to the cache does occur, though i dont understand why it is needed (the code was ported from a sqlsitemapprovider). doesnt asp.net cache the data on its own? it definetly does.
Can someone help me get my data invalidated or whatever?
my db show that Is_Broker_Enabled is on
I have coded a LINQ SiteMapProvider for my ASP.NET site. The site pages info is stored in a MSSQL database.
When I make changes to the SitePAges table, the SiteMap does not reset. Here is my code
ASP.NET Syntax (Toggle Plain Text)
Public Overrides Function BuildSiteMap() As System.Web.SiteMapNode If RootMapNode IsNot Nothing Then Return RootMapNode dcx = New GrabdayDataContext RootMapNode = Nothing Dim SitePages = From q In dcx.SitePages Where q.ParentID Is Nothing Dim cmd As New SqlCommand("select sitepageid, parentid from SitePages", New SqlConnection(ConfigurationManager.ConnectionStrings("Grabday").ConnectionString)) Dim dependency = New SqlCacheDependency(cmd) RootMapNode = SitePageNode(SitePages.FirstOrDefault) AddNode(RootMapNode, Nothing) AddChildNodes(RootMapNode, SitePages.FirstOrDefault) HttpRuntime.Cache.Insert(_cacheDependencyName, New Object(), dependency, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, New CacheItemRemovedCallback(AddressOf OnSiteMapChanged)) Return RootMapNode End Function Sub OnSiteMapChanged() Clear() End Sub
My debugging shows that the "Insert" code to the cache does occur, though i dont understand why it is needed (the code was ported from a sqlsitemapprovider). doesnt asp.net cache the data on its own? it definetly does.
Can someone help me get my data invalidated or whatever?
my db show that Is_Broker_Enabled is on
•
•
Join Date: Feb 2009
Posts: 8
Reputation:
Solved Threads: 0
hi
soory, i havent meant to skimp. I just thought to keep the code to only waht is necessary.
I am going over the article you sent me, meanwhile, here is the complete Provider Class
Please point out where im misatking
thanks
soory, i havent meant to skimp. I just thought to keep the code to only waht is necessary.
I am going over the article you sent me, meanwhile, here is the complete Provider Class
Please point out where im misatking
thanks
ASP.NET Syntax (Toggle Plain Text)
Imports System.Collections.Specialized Imports System.Data.SqlClient Imports System.Configuration Imports System.Web.Caching Imports System.Collections.Generic Public Class LINQSiteMapProvider Inherits StaticSiteMapProvider Dim dcx As GrabdayDataContext Dim RootMapNode As SiteMapNode Dim UserID As Integer Const _cacheDependencyName As String = "__SiteMapCacheDependency" Public Overrides Sub Initialize(ByVal name As String, ByVal attributes As System.Collections.Specialized.NameValueCollection) MyBase.Initialize(name, attributes) dcx = New GrabdayDataContext End Sub Public Overrides Function BuildSiteMap() As System.Web.SiteMapNode If RootMapNode IsNot Nothing Then Return RootMapNode dcx = New GrabdayDataContext RootMapNode = Nothing Dim SitePages = From q In dcx.SitePages Where q.ParentID Is Nothing Dim cmd As New SqlCommand("select sitepageid, parentid from SitePages", New SqlConnection(ConfigurationManager.ConnectionStrings("Grabday").ConnectionString)) Dim dependency = New SqlCacheDependency(cmd) RootMapNode = SitePageNode(SitePages.FirstOrDefault) AddNode(RootMapNode, Nothing) AddChildNodes(RootMapNode, SitePages.FirstOrDefault) HttpRuntime.Cache.Insert(_cacheDependencyName, New Object(), dependency, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, New CacheItemRemovedCallback(AddressOf OnSiteMapChanged)) Return RootMapNode End Function Protected Overrides Function GetRootNodeCore() As System.Web.SiteMapNode BuildSiteMap() Return RootMapNode End Function Sub AddChildNodes(ByVal ParentNode As SiteMapNode, ByVal ParentPage As SitePage) Dim childs = From q In dcx.SitePages Where q.ParentID = ParentPage.SitePageID Dim NewNode As SiteMapNode For Each sp In childs NewNode = SitePageNode(sp) AddNode(NewNode, ParentNode) AddChildNodes(NewNode, sp) Next If ParentPage.PageName = "OrdersByStatus" Then Dim statusses = From q In dcx.OrderEvents Select q.Brief Distinct Dim roles As String() = {} Dim nvc As New NameValueCollection nvc.Item("PageName") = "Orders" For Each os As String In statusses NewNode = New SiteMapNode(Me, os & "Orders", "~\Admin\Orders.aspx?Status=" & os, os & " Orders", os & " Orders", roles, nvc, New NameValueCollection, "") AddNode(NewNode, ParentNode) Next End If End Sub Function SitePageNode(ByVal SitePage As SitePage) As SiteMapNode Dim nvc As New NameValueCollection nvc.Item("PageName") = SitePage.PageName Dim roles As String() = {} Return New SiteMapNode(Me, SitePage.SitePageID, If(SitePage.URL, "~\Admin\Menu.aspx" & "?ID=" & SitePage.SitePageID), SitePage.Title, SitePage.Description, roles, nvc, New NameValueCollection, "") End Function Sub OnSiteMapChanged() Clear() End Sub End Class
![]() |
Similar Threads
- WinXP User Accounts Issue (Windows NT / 2000 / XP)
- Having roblems using PHP to send info as text file (PHP)
- Can't access some websites (Viruses, Spyware and other Nasties)
- Merging And Splitting (Java)
- Backing up a MySQL database (MySQL)
- Help with Trojan.bookmarker.gen (Viruses, Spyware and other Nasties)
- Internet Explorer Fails After Registry Removal (Viruses, Spyware and other Nasties)
- PayPal password issue (Web Browsers)
- Stay Up to Date Automatically (Windows tips 'n' tweaks)
Other Threads in the ASP.NET Forum
- Previous Thread: Flv Player in ASP.NET
- Next Thread: Notify alert message while navigating to other page
Views: 563 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 3.5 2008 access ajax alltypeofvideos appliances application asp asp.net beginner box browser button c# cac chat checkbox complex control dataaccesslayer database datagridview datalist development dgv dialog directshow dropdownlist dynamically edit editing editor feedback fileuploader fill flash form gridview gudi iis iis-application image india insert javascript linq-sql list listbox login microsoft mouse mssql news numerical opera parent problem project radio redirect registration relationaldatabases reportemail response.redirect result richtextbox rows running schoolproject search security select server session sessionvariables silverlight simple smoobjects software sql sql-server subdomain theft tracking treeview trust-level update validatedate validation vb.net videos vista visualstudio web webapplications webprogramming website xsl






