locked
Sharing session state using web.config not reflection RRS feed

  • Question

  • User-1876259718 posted

    Hi everybody,

    I'm sharing session variables in two different asp.net web applications.

    I'm using "StateServer" mode.

    For sharing, i set _appDomainAppId of the HttpRuntime same for applications with using reflection. In Application_Start function, here is my code:

    string applicationName = "mysite"
    
    FieldInfo runtimeInfo = typeof(HttpRuntime).GetField("_theRuntime",BindingFlags.Static | BindingFlags.NonPublic);
    
    HttpRuntime theRuntime = (HttpRuntime)runtimeInfo.GetValue(null);
    
    FieldInfo appNameInfo = typeof(HttpRuntime).GetField("_appDomainAppId",BindingFlags.Instance | BindingFlags.NonPublic);
    
    appNameInfo.SetValue(theRuntime, applicationName);

    Here is my question : I don't want to use reflection for this. I want to handle this in web.config.

    Is there any way to set _appDomainAppId in web.config ? I couldn't find anything under the httpRuntime section or anywhere else.

    Thank you.

    Sunday, November 11, 2012 7:49 PM

All replies

  • User-837620913 posted

    There is no built-in way to do it from the web.config. Doing it using reflection is the only way to change it after the application starts.

    Monday, November 12, 2012 5:34 AM
  • User482643855 posted

    Not possible by web.config.

    Thursday, November 15, 2012 6:58 AM
  • User200382248 posted

    Hi,

    Mybe you can try to configure you web.config to use "sqlserver" mode session state.

    <sessionState 
                mode="SQLServer"
                sqlConnectionString="data source=127.0.0.1;user id=<username>;password=<strongpassword>"
                cookieless="false" 
                timeout="20" 
        />

    More information please follow: http://support.microsoft.com/kb/317604?wa=wsignin1.0

    Thursday, December 13, 2012 6:59 AM
  • User-861818263 posted

    you can use SQL server to store session state ,

    Please see :- 

    http://support.microsoft.com/kb/317604

    Monday, December 17, 2012 5:36 AM