.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


Posted By:      Posted Date: October 21, 2010    Points: 0   Category :ASP.Net

Hi there,

In two applications of mine I changes my web.config session tag to the following -

 sqlConnectionString="data source=data.source.com;user id=user;password=password; "></sessionState>

in order to navigae from one application to the other and maintain the session variables.

When I redirect (using code) from one application to the other I am losing my session variables.

What am I doing wrong ?

How can I read session variable that were created on siteA in siteB

View Complete Post

More Related Resource Links

Access SessionState: via App1 to SessionState from App2


Hi .NET'ers,

i'm interested to do the following - i geuss, i have no option to do that:

we have our "mainapplication" on a DB; we are tracking user-login status by switching a bit in the DB in the users data row.

we hvae a second application, the backend, which is the administration tool.

(the applications are put in seperate diretories on HD)

sometimes, we need to block/ban users. in some cases the users are logged in, when we "see them in action".

i'd like to build a button in the backend-application, which logss-out the user from the mainapplication.

for sure: i can access the same DB and switch the bit to "know" he's offline, but this will not kill the session on the mainapplication.

because: if a user is on/offline is also indicated by the session in the IIS.
and as the IIS-session is active, the user may be already banned - but he will not be logged out automatically (and showing something like "you have been logged out because of a ban)

one option would be to call the DB by each page-load to find out, if the user is logged on.

is there any option to implement this?

Enable sessionstate

I got  following error message "Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the <configuration>\<system.web>\<httpModules> section in the application configuration"   I searched in google , someone say <%@ Page enableSessionState = "true" %>in page or web.config I put the above code in web.config and page also. I got the same message. It works well in my local machine, i got the above error in server only how to fix this error? 

SessionState works in VWD 2010 Debug, IIS 5.1 but not on WS2008 (IIS7.5)

Hi,I'm building a site using the .NET 4 framework using routing and MasterPages.Because I'm using both routing and MasterPages, I can't see any way how to get value from control on the previous page. To solve this I've used the code behind to store the control's value in a session variable. Is there a way to retrieve a value from a control using PreviousPage or something when using Routing and MasterPages?This works fine in VWD debug mode and in IIS 5.1, but when I try to deploy it on my Windows Server 2008 (IIS7.5) machine, it get this error:Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the <configuration>\<system.web>\<httpModules> section in the application configuration.Here is a copy of my web.config file:<configuration> <appSettings></appSettings> <system.webServer> <handlers></handlers> <modules> <remove name="UrlRoutingModule-4.0"/> <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition=""/> </modules> </system.webServer> <connectionStrings> </connectionStrings> <system.web>

sessionstate timeout

 In my web.config I have the following: sessionState timeout=20 In my Global.asax I have the following: Session.Timeout = 20 How long will it be before a user is booted back to the login page, if they don't do anything in the app?

Serializing / Storing VS2010 generated WCF Proxy Class reference in SQL SessionState



I have a WCF 4 service being consumed by an ASP.NET 3.5 (SharePoint 2010 actually) application.

Because we have implemented session support in the WCF service (ws2007HttpBinding) to maintain some objects that are very expensive to intialize, I'm also trying to keep my service client reference persisted on the ASP.NET consumer-side. However in order to persist it across post-backs, I need to add it to the session (using SharePoint's SQL SessionState provider), and this causes serialization (binary serialization) of the WCF service referece.

The ASP.NET application is throwing an error, because it cannot serialize the WCF service reference.

Any thoughts?

SharePoint SessionState and WCF Serialization



In a nutshell, I'm unable to add a reference to a WCF service to the Session object in a SharePoint 2010 application page, because it claims that the object is non-serializable. Further details:

SessionState support has been enabled in SharePoint (which uses SQL SessionState), and I'm trying to persist a reference to my WCF connection into the Session object, since the WCF connection is stateful. I know that WCF should ideally be stateless, however the WCF server is initializing some objects that are expensive to intialize, and we need it to try and persist the data per session as much as possible. The same WCF service also in use by a standard ASP.NET application, which has no issues since it uses in-memory sessions, which do not require serialization.

The problem is that the WCF proxy class is not marked serializable (and editing the proxy class to mark it serializable doesn't help), and therefore adding it to the Session fails because in SharePoint / SQL SessionState all objects must be binary serializable.

Exact error is:

Exception type: SerializationException 
  Exception message: Type 'Contoso.CNDataServiceClient' in Assembly 'Contoso.Wss4Pages, Version=, Culture=neutral, PublicKeyToken=123b132913982371' is not marked as serializable. 

I was wondering if anyone had any guidance / suggestion

cookieless="false" in sessionState

what is the means for cookieless="false".
is it means that session data would be stored in cookies

SQLServer sessionState


Am having trouble with SQLserver session state.  I'm trying to get session state to work across multiple domains (in this case multiple virtual folders - for testing purposes)

I have two virtual folders:

  1. Vfolder1
  2. Vfolder2

Both have a web.config file with the following:

sqlConnectionString="data source=localhost;Integrated Security=SSPI"
timeout="20" />

but for some reason when I login to Vfolder1 and then goto Vfolder2 I'm not logged in on Vfolder2 website, any ideas welcome?

ASP.Net 4 Problem with Session - System.Web.SessionState.HttpSessionState


I am building the Tailspin Shopping Cart from the asp.net http://www.asp.net/web-forms 

I am trying to put in this code into a Class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using uboPrducts.Data_Access;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace uboPrducts.Classes
    public struct ShoppingCartUpdates
        public int ProductId;
        public int PurchaseQantity;
        public bool RemoveItem;

    public partial class MyShoppingCart
        public const string CartId = "TailSpinSpyWorks_CartID";

        public String GetShoppingCartId()
            if (Session[CartId] == null)
                Session[CartId] = System.Web.HttpContext.Current.Request.IsAuthenticated ? User.Identity.Name : Guid.NewGuid().ToString();
            return Session[CartId].ToString();

I get 4 errors from the above few lines. It says that Session is "The name Session does not exist in the current context"

When I go to the downloaded program and open it (note I

Firefox VS IE(regarding Sessionstate)


Hi all,

I have the following problem.In my application I use sessions.if i disable cookies in IE,even if i do not include in the webconfig file the line <Sessionstate cookieless="Autodetect" regenerateExpiredSessionID="true"/> ,it will work!

On the other hand,if I disable cookies in firefox and it will not work!I won;t be able to access the application unless I enable cookies.Even if I include the sessionstate line as above,still IT WILL NOT WORK IN FIREFOX!!


In short,the firexof,no matter what I do,if cookies are disabled,it will not work!


Please any help will be appreciated!!


Custom SessionState provider & web services problem


My .Net Framework 3.5 web application uses MySql database accessed by .Net Connector 6.3.3. I use it's membership provider too. Recently I replaced InProc SessionState provider to MySql custom provider.

After this web services in application stopped working. Instead of something useful any webservice method returns html page with description of web service generated by IIS/ASP.NET.

I'm not using session state in web methods and they are declared with simple [WebMethod] attribute, so EnableSession has its default value - false. I've tried also the simple Hello World web service to be sure I'm not doing something different in my web services.

This problem occurs only with SOAP. HTTP POST is ok, so invoking web service method  on  IIS generated page works as before.

Because I didn't find anything useful I'd like to ask if there is solution for this custom SessionState / webservice combination problem. I don't know if it is specific for MySql or not.

SessionState in HttpModule problem (2.0)


Hello Developers,

I have an interesting problem. How, or when can I access SessionState from
the HttpModule?
It seems that session state is only available when *.aspx page is requested.
It is not available when other, "static" resources, like *.gif files are handled.

Is there any way I can force session state to load, even when it is not
*.aspx page being requested?

What I am trying to develop is a special kind of rewrite engine. It must
have access to session state.

Thank you,
Tomasz J

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