0

I have a ASCX control that sits inside of a CMS that is written in .net, the problem I am running into is that we have pass a variable called fullname in our headers. We have a simple script that reads this variable and then outputs the name in the page. But sometimes some users will get completely random users name (I have verified that they have not logged into that machine which tells me this must be some sort of server side caching going on). I was thinking about using SetCacheability but am not sure if this will cause the entire page to not be cached or just the ascx control that loads on the page. Any ideas on what to do?

        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        if (!String.IsNullOrEmpty(this.UserName))
        {
            lblUsername.Text = Request.ServerVariables["fullname"].ToString();
        }
1
  • It is specifically advised not to put user information in the headers as it can be easily faked/forged: msdn.microsoft.com/en-us/library/ms525396(v=vs.90).aspx. How are you authenticating users? As each user should get their own session, the fact that some users can appear as others is a weird one. I wonder if the process that originally picks up the user's full name is getting the wrong one. Commented Dec 7, 2011 at 21:08

1 Answer 1

2

You can declare an @OutputCache attribute in your ASCX markup and set his properties as Duration="0" VarByParam="None" (documentation).

Also you can take a look on "Caching portions of an ASP.NET Page" article and "Dynamically Updating Portions of a cached page".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.