.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

Access SessionState: via App1 to SessionState from App2

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

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?

View Complete Post

More Related Resource Links

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?



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

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

MVC architecture in ASP.Net using C# and Microsoft Data Access Application block

The Model-View-Controller (MVC) pattern separates the modeling of the domain, the presentation, and the actions based on user input into three separate classes [Burbeck92]:

Model. The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller).

View. The view manages the display of information.

Controller. The controller interprets the mouse and keyboard inputs from the user, informing the model and/or the view to change as appropriate.

Store and Display Images from MS Access Database Using C#

There is only the difference of coding syntax to stream the binary data of image content type to upload it into MS Access Database using C#/VB in ASP.Net 2.0

Namespaces required:-
using System.Data.OleDb;

OleDb is used to connect the web site forms with MS Access Database using Microsoft.Jet.OLEDB.4.0

ASP.Net Upload Image to MS Access Database

As you learnt from the previous articles to upload image to the SQL Database in ASP.Net 2.0 and stream that image into the memory to retrieve it from the database and display it on the web page. In this article you will learn how to upload images to the MS Access database in ASP.Net 2.0

First of all create an Access Database and place it in the App_Data folder of ASP.Net web site project. Then create a table "tblImg" with the following fields:

Wrong Account being used to access files - Help - No Impersonation


I run a simple .aspx website on a Windows Server 2008 machine.

There is NO impersonation, and System.Security.Principal.WindowsIdentity.GetCurrent().Name returns NT AUTHORITY\NETWORK SERVICE, which it the account which the application pool runs. In my web.config, I have <authentication mode="Forms">.


I tried to test the security of the application and server by removing file permissions to the .aspx files. I was greatly worried when the website continued to run without problem (it should not have been able to read the .aspx files).

By turning on file level auditing, I discovered that the .aspx files were being read by the machine$ account (if the machine is called Serv1, then the files would be read by the Serv1$ account, which seems to have access to all files on the local machine).


Is this a security breach or is this behaviour by design ?

Please can somebody assist, as I am worried.

Disallow Direct Access To Files



Here is my dilema, on my site i have a WordPress Audio player (http://wpaudioplayer.com/standalone) that plays my mp3's.

It loads the Mp3's in by javascript...example below:

       AudioPlayer.embed("audioplayer_7", { soundFile: "/Files/Music/[name of file].mp3" });

This file name is clearly visible in the browser source. Not a problem, however this means that any user can legitimately browse to the file directly and download it.

Now i still need the mp3 player (which is flash) to have access to the file but if a user was to try accessing the file directly, they would not be allowed access to it.

I am not sure how to go about this, i am circling the idea of a httphandler but not sure if this is sufficiant to stop the direct access to the file.

Any help would be appreciated

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