user control caching

F

fernandezr

I have a navigation user control built using a sqlsitemap in our site's
master page. After a user logs in the control doesn't refresh the data
in the leftside navigation links. I found I can force it to refresh if
I simply resave one of the files in my project. These links then cache
after I logout until I resave a project file again.

How can I force the user control to refresh the data when a user logs
in and logs out?

Thanks,
Happy Friday,
Robert
 
F

fernandezr

I still haven't resolved this issue but I've narrowed it down to one
area of code. I turned on tracing and found that when my menu control
class gets to the HierarchicalDataSourceView view = base.GetData("");
line of the following code

protected override void PerformDataBinding()
{
HttpContext.Current.Trace.Write("menu.cs",
"PerformDataBinding()");
SiteMapDataSource dataSource = null;
HierarchicalDataSourceView view = base.GetData("");

HttpContext.Current.Trace.Write("menu.cs",
"HierarchicalDataSourceView view");
// if there's no data source don't bind
if (!base.IsBoundUsingDataSourceID && (this.DataSource ==
null))
return;

it calls the Initialize() method of my SqlSiteMapProvider and the
navigation menu is updated. After this occurs it will not call my
SqlSiteMapProvider again unless I resave a file in my project.

Why is it only calling it once? I like this caching effect only when
the user is logged in. How can I control when this SiteSiteMapProvider
is called?

Thanks,
Happy Friday,
Robert
 
F

fernandezr

In case anyone is interested in how I solved this... I found that
after the SiteMapProvider was called the first time it was filled with
nodes and would keep returning when it got to the following statement.

if (_root != null)
return _root;

I now control how often the database is called by creating a session
variable LoadLinks which I toggle yes/no.

public override SiteMapNode BuildSiteMap()
{

if (HttpContext.Current.Session["LoadLinks"] == "Y")
{
HttpContext.Current.Session["LoadLinks"] = "N";
Clear();
_nodes.Clear();
_root = null;
}

lock (_lock)
{
// Return immediately if this method has been called before
if (_root != null)
return _root;

Happy Thursday,
Robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top