1

Thanks for taking a look.

I have a text box and a button on a SharePoint aspx page which will update the current SPWeb's title. The control then redirects the user to a different .aspx page in the same Web.

The web title gets updated, and all processing behaves as normal. The problem is that on this initial redirect the QuickLaunch and breadcrumb still display the old title. Only after the user manually refreshes one time do the QuickLaunch and breadcrumb elements get updated.

Here is the code:

    public string ChangeWebTitleElevated(string webUrl, string newTitle)
    {
        string updatedTitle = "";

        try
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(webUrl))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        web.Title = newTitle;

                        web.AllowUnsafeUpdates = true;
                        web.Update();
                        web.AllowUnsafeUpdates = false;

                        updatedTitle = newTitle;
                    }
                }

            });
        }
        catch(Exception ex)
        {
            Logging.LogError("ChangeWebTitleElevated: webUrl: " + webUrl + ", New Title: " + newTitle + ", Exception: " + ex.ToString());
        }

        return updatedTitle;
    }

    protected void SaveProfileClick(object sender, EventArgs e)
    {
        ChangeWebTitleElevated(SPContext.Current.Web.Url, "New Web Title");

        //Response.Expires = -1;
        //Response.Cache.SetCacheability(HttpCacheability.NoCache);
        //Response.Redirect(SPContext.Current.Web.Url + "/pages/home.aspx");

        SPUtility.Redirect(SPContext.Current.Web.Url + "/pages/home.aspx"), SPRedirectFlags.Static, HttpContext.Current);

     }

As you can I've done some investigation around caching with a Response.Redirect (using Expires=-1 and SetCacheability) but they all showed the same issues.

Does anyone know of a workaround for this? Thank you in advance.

-Phillip

2
  • This may have something to do with caching? Is it possible to refresh their cache programatically? Just a thought.
    – Mike
    Dec 10, 2012 at 22:54
  • I can look into this, but my assumption is that if client caching is indeed the case, then a simple refresh would not solve the issue. The client would have to flush cache before he/she would be able to see changes. In this example, the user just refreshes and the QL shows up correctly.
    – phil
    Dec 10, 2012 at 23:16

1 Answer 1

0

The client ended up being OK with the delay and having to refresh for changes to take affect. We added a message: "please allow a few moments.." etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.