Sharing ASP.NET Session State through different web applications

N

Nabani Silva

Hi, hope someone could help

I need to share session state (and contents) through differente web
applications.

I'm trying to get it done by using StateServer session state, below I paste
code for web.config. Both applications are on the same server (I don't want
to include all applications into one common virtual directory or
application)

Anything goes fine, same sessionid on both apps but if I set one session
variable on one application it is not available on the other application.
Object set on session is serializable. This is how I'm setting and getting
session vars:

App1:

private void Page_Load(object sender, System.EventArgs e)

{

Session["Example"] = new Example(10);

Response.Redirect("app2.aspx");

}

App2:

private void Page_Load(object sender, System.EventArgs e)

{

Example exmp = (Example)Session["Example"];

//and.... exmp is null : (

}


Thanks in advance
Nabani.

***********************************************
web.config (same code for both applications)
***********************************************

<?xml version="1.0" encoding="utf-8" ?>

<configuration>


<appSettings>

<add key="DataConnectString" value="DSN=dnsname;TRUSTED_CONNECTION=Yes" />

</appSettings>


<system.web>

<!-- DYNAMIC DEBUG COMPILATION

Set compilation debug="true" to enable ASPX debugging. Otherwise, setting
this value to

false will improve runtime performance of this application.

Set compilation debug="true" to insert debugging symbols (.pdb information)

into the compiled page. Because this creates a larger file that executes

more slowly, you should set this value to true only when debugging and to

false at all other times. For more information, refer to the documentation
about

debugging ASP.NET files.

-->

<compilation

defaultLanguage="c#"

debug="true"

/>

<!-- CUSTOM ERROR MESSAGES

Set customErrors mode="On" or "RemoteOnly" to enable custom error messages,
"Off" to disable.

Add <error> tags for each of the errors you want to handle.

"On" Always display custom (friendly) messages.

"Off" Always display detailed ASP.NET error information.

"RemoteOnly" Display custom (friendly) messages only to users not running

on the local Web server. This setting is recommended for security purposes,
so

that you do not display application detail information to remote clients.

-->

<customErrors

mode="RemoteOnly"

/>

<!-- AUTHENTICATION

This section sets the authentication policies of the application. Possible
modes are "Windows",

"Forms", "Passport" and "None"

"None" No authentication is performed.

"Windows" IIS performs authentication (Basic, Digest, or Integrated Windows)
according to

its settings for the application. Anonymous access must be disabled in IIS.

"Forms" You provide a custom form (Web page) for users to enter their
credentials, and then

you authenticate them in your application. A user credential token is stored
in a cookie.

"Passport" Authentication is performed via a centralized authentication
service provided

by Microsoft that offers a single logon and core profile services for member
sites.

-->

<authentication mode="Forms">

<forms name="forma" loginUrl="/common/login.aspx" protection="All"
timeout="150" path="/"></forms>

</authentication>


<machineKey
validationKey="A50B3C89CB21F4F1422FF158A5B42D0E8DB8CBCDA1742572A487D9401E3400267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABB"

decryptionKey="VA9BE8FD67AF6979E7D20198CFEA50DD3D3799C77AF2B72B"
validation="SHA1" />



<!-- AUTHORIZATION

This section sets the authorization policies of the application. You can
allow or deny access

to application resources by user or role. Wildcards: "*" mean everyone, "?"
means anonymous

(unauthenticated) users.

-->

<authorization>

<allow users="*" /> <!-- Allow all users -->

<!-- <allow users="[comma separated list of users]"

roles="[comma separated list of roles]"/>

<deny users="[comma separated list of users]"

roles="[comma separated list of roles]"/>

-->

</authorization>

<!-- APPLICATION-LEVEL TRACE LOGGING

Application-level tracing enables trace log output for every page within an
application.

Set trace enabled="true" to enable application trace logging. If
pageOutput="true", the

trace information will be displayed at the bottom of each page. Otherwise,
you can view the

application trace log by browsing the "trace.axd" page from your web
application

root.

-->

<trace

enabled="false"

requestLimit="10"

pageOutput="false"

traceMode="SortByTime"

localOnly="true"

/>

<!-- SESSION STATE SETTINGS

By default ASP.NET uses cookies to identify which requests belong to a
particular session.

If cookies are not available, a session can be tracked by adding a session
identifier to the URL.

To disable cookies, set sessionState cookieless="true".

-->

<sessionState

mode="StateServer"

stateConne!tionString="tcpip=127.0.0.1:42424"

cookieless="false"

timeout="20"

/>

<!-- GLOBALIZATION

This section sets the globalization settings of the application.

-->

<globalization

requestEncoding="utf-8"

responseEn!oding="utf-8"

culture="es-MX"

uiCulture="es-MX"

/>


<!-- PREVENT SOURCE CODE DOWNLOAD

This section sets the types of files that will not be downloaded. As well as
entering

a httphandler for a file type, you must also associate that file type with
the xspisapi.dll

in the App Mappings property of the web site, or the file can be downloaded.

It is recommended that you use this section to prevent your sources being
downloaded.

-->

<httpHandlers>

<add verb="*" path="*.vb" type="System.Web.HttpForbiddenHandler" />

<add verb="*" path="*.cs" type="System.Web.HttpForbiddenHandler" />

<add verb="*" path="*.vbproj" type="System.Web.HttpForbiddenHandler" />

<add verb="*" path="*.csproj" type="System.Web.HttpForbiddenHandler" />

<add verb="*" path="*.webinfo" type="System.Web.HttpForbiddenHandler" />

</httpHandlers>


</system.web>

</configuration>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top