.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Apparently missing something in my understanding of session handler...

Posted By:      Posted Date: August 24, 2010    Points: 0   Category :ASP.Net

 It was doing exactly what I expected until I added more than 1 property to it.   It seems if I set the value of a property this, in turn, sets every property in the handler to the same value.  It's blatantly obvious I didn't have the understanding I thought I did on this.  :-)

Could someone point out what I'm missing?  I figured it had something to do with the "shared" but if it's not shared then I would have to declare an instance on my page which would kinda ruin the state of my variables (otherwise, I'd just put them all in my class), right??

Private Shared _strStudentName As String
Private Shared _strSchoolID As String

    Public Shared Property StudentName() As String


            If (HttpContext.Current.Session(SessionHandler._strStudentName) Is Nothing) Then
                Return String.Empty
                Return HttpContext.Current.Session(SessionHandler._strStudentName).ToString()
            End If

        End Get

        Set(ByVal value As String)
            HttpContext.Current.Session(SessionHandler._strStudentName) = value
        End Set

    End Property

    Public Shared Property SchoolID() As String


            If (HttpContext.Current.Session(SessionHandler._strSchoo

View Complete Post

More Related Resource Links

Event handler lightning bolt missing in VS2010


I have recently upgraded from VS2008 to VS2010 after a few months away from ASP.NET coding and I am hitting a problem I never had before. I seem to remember having a lightning bolt icon in the properties window for a web form that would automatically create the skeleton event handler code for any one of a range of page events. However, I cannot see this lightning bolt anywhere in VS2010.

Some guidance would be much appreciated. It would be a chore to have to create this code every time from scratch.


ModelChanged event handler missing event args

I have implemented a ModelChanged event handler in my AddDesigner call as follows:

             _wd.ModelChanged += wd_ModelChanged;

The code for the ModelChanged event is:

private void wd_ModelChanged(object sender, EventArgs e)
            ModelChangedEventArgs changedEventArgs = e as ModelChangedEventArgs;

            if(changedEventArgs != null)
                IEnumerable<ModelItem> itemsRemoved = changedEventArgs.ItemsRemoved;

                foreach (ModelItem modelItem in itemsRemoved)
                    if (modelItem.ItemType == typeof(Flowchart))
                        MessageBox.Show("You can not delete the base flow chart!", _appName, MessageBoxButton.OK, MessageBoxImage.Stop);

            //Add the expression text boxes to all switch and descision flow activities

The issue I have is that there are no event args coming through, when I expected there to be event arguments from the editing context. Any ideas on what I have missed?

Session identifier missing until a couple of calls done to webservice



I use the ReportExecution2005 service to render reports and on the first rendering of the stylesheet, and on the first call to ToggleItem I get "A session identifier is required for this operation" exception. If I go back to the first "get" to my page and click ctrl+F5 it starts behaving well. Stylesheet and toggling works as expected.

In my local environment, both on my computer and testserver (64bit) it works first time, but in my customers environment (64bit) it fails as described. I've checked that we've got exactly the same version of SQL Server.

Any ideas where to start debugging?


missing call to linkbutton handler


When I click a linkbutton that was pragramatically added, why in Page_Load() do I need to refresh the page in order for the linkbutton event to be called?

I click linkbutton, Page_Load is called, if I refresh the entire page, then the event handler for linkbutton is called, and all is well.

I click linkbutton, Page_Load is called, if I don't refresh, then Page_Load returns, and the linkbutton handler is never called.


Truly Understanding View State

This article provides a detailed understanding of the ViewState.

MS SQL Server: Disconnect Users From Database - Kill User Session

If you ever wanted to restore your database from a SQL backup file (.bak), but there are still users connected to your database, the backup operation will fail causing the error: Exclusive access could not be obtained because the database is in use.

Content Query Web Part missing in SharePoint 2010

If you don't see content query web part listed in the web parts list, this is because you have not enabled "Search Server Web Parts" feature in site collection features. Enable this feature and content query web part will show in the list of web parts.

Missing 'new item templates'


 Hi all,

          I am a 'newbie' to VWD and I am slowly working through the Basic Walkthrough Help files, and learning plenty along the way.

However, when I tried to create a new database in the LINQ control walkthrough I found that the option to create a new database is missing, and further investigation has found that many other new item templates are missing.

I am using a brand new machine with Windows 7 Ultimate and have enabled IIS and .NET from Control Panel-Programs-Turn Windows Features On-Off. I used the WPI to install all basic elements eg. IIS Components, SQL Server Express.

The only 'new item templates' I have when I right-click the App_Data Folder and choose 'new item' are:-

ADO.NET Data Service

AJAX Enabled WCF Service

Dynamic Data Field

SQL Server Database

Text File

XML File

Does anyone know where I have gone wrong.


Michael J. Hill

SQL Server Session state problem.


Hi to all,

I have some things that I want to know. I am right now using a free asp.net webhosting ("somee.com"). The problem is that when I am visiting a page, there's a tendency that values stored in my session variables are lost. Therefore, it causes an error when the requested page is loaded.

1. I am thinking of using sessionState mode="SqlServer". Will it solve my problem?

Actualy Im working on it but Im having problems when connecting to the sql database.

2.  Is that a problem in the webhost?

3. Do free webhosting sites provide allow session state in the sql server?. Because ive tried it locally into my computer and error say's i should intall the ASP.NET Session State SQL Server version 2.0 or above.

Session and Application Variables


I have a web application in which i need to logout the user if he clicks the logout button or even if he closes his browser window. On Logout button click, i am doing session.Abandon(), but how to go about his browser window close.

Can anybody help with a code sample.

Is there any way to find out the reason for session expiry?


Dear All,

is there any way to find out the reason for session expiry?



Session time out earlyer with in 5 min.


In my live site session time out with in 5 min only.how can i get the default i.e 20 min time . below webconfig file give below

<?xml version="1.0"?>
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
        <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, &#xA;        System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, &#xA;        PublicKeyToken=31bf3856ad364e35">
            <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, &#xA;        System.Web.Extensions, Ver

Datatable in session


I am creating a simple shopping cart using a datatable that is passed into a session object.  I have a small mini cart that displays the total number of items in the cart as well as the running total - this is displayed in a web control.  When the web control starts up I run a try/catch to see if the session object exists, if it doesn't I create the datatable for the cart and store it in the session.  I then have a datalist control that contains all the information for my products including an "add to cart" button.  When the page loads everything looks fine.  If I click on an "add to cart" button nothing happens to the session information.  If I click on it again, the session information updates - displaying only one item is in the cart and then counts up correctly there after.  Additionally, after adding an item, if I select a different item in the list, the same issue occurs.  I am not sure why this is happeing, if anyone can give me an idea I would appreciate it. 



Hi friends

I m facing a problem in my application with server so it needs changes .

My question is

Q1.Where should I store my session if i want to disconnect my server or How shold we storesession in web farm if specific serever is shut down.

Q2.Can anyone explain me difference between WEB FARM and WEB GARDEN






Session Timeouts


What are the issues (if any) of setting sessions to expire after an extended period of time as in 4-8 hours? I'm building an intranet app which is designed so that users will access it once in the morning and then leave it used, possibly, for hours at a time. I'm assuming that there aren't too many since

1) we're running it on a intranet
2) sessions are soley to retain state between requests
3) its not like a connection to the DB where you can conceivable run out

holding datatable value using session



iam insert record using datable in gridivew,iam using  session to hold the record,

there is any other way to hold the record in datable.


        DataRow row;
        row = dtempty.NewRow();
        row["ratetypeid"] = ddlratetype.SelectedValue;
        row["ratedesc"] = ddlratetype.SelectedItem.Text;
        row["slabs"] = ddlslabs.SelectedValue;   

Session with Crystal Reports on IE 8



Having a very wierd problem.  I have an application that uses Crystal Reports and it uses what I have found to be a common scenario (I am not a CR expert in any way).  I have an ASPX page that gathers options for the report, and then it goes and gets the data and if there is some, a button appears for them to launch the report.  On clicking that button, the code sets some values in the HttpResponse.Context area, then performs a Server.Transfer to another ASPX page that is our Report Template.  This page contains the CR stuff and it generates a PDF version of the report.  It then does the following code:

 With HttpContext.Current.Response
            .ContentType = "application/pdf"
            .AddHeader("Content-Disposition", "inline; filename=Report.pdf")

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend