Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Session variables in code behind file
Message
Information générale
Forum:
ASP.NET
Catégorie:
Visual Studio
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01521931
Message ID:
01521942
Vues:
30
>Hello all,
>
>I just successfully converted my web application to VS 2010 from VS 2008 and found out that when there are session variables in the code behind file for a web form, the design form view encounters an error in rendering the page on the design form. The following link explains this:
>
>http://blogs.msdn.com/b/webdevtools/archive/2010/04/15/rendering-issue-in-visual-studio-2010-when-accessing-the-session-state-in-the-oninit-method.aspx
>
>I would like to know how any of you who have encountered this have addressed this issue.

The work-around in the link seems to be the way to go. I suppose if you have a *lot* of session variables then it might be worth a method to handle it:
public partial class Junk : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string s = (string) GetSessionValue("Something");
            //etc
        }
        object GetSessionValue(string s)
        {
            return (Context != null && Context.Session != null) ? Session[s] : null;
        }
    }
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform