.
Anmeldung | Registrieren | Hilfe
in Suchen

Session variable loses value in asp.net application

Letzter Beitrag 24. Jun 2016 10:07 von haruka. 0 Antworten.
Seite 1 von 1 (1 Treffer)
Beiträge sortieren: Zurück Weiter
  • 24. Jun 2016 10:07

    • haruka
    • Nicht gereiht
    • Registriert am 01. Jun 2016
    • Beiträge 2
    • Punkte 5

    Session variable loses value in asp.net application

    In my asp.net application I have a few session variables. Seems like only a few minutes on the localhost and also web host, they lose value. This happens periodically not all of the time. I do have cheap asphostportal web hosting, and that could be the problem on the web server. Thank you for any help, this is a big problem.

    <pre class="lang-cs prettyprint prettyprinted"><code><span class="pln"> </span><span class="pun"><</span><span class="pln">authentication mode</span><span class="pun">=</span><span class="str">"Forms"</span><span class="pun">></span><span class="pln">
          </span><span class="pun"><</span><span class="pln">forms loginUrl</span><span class="pun">=</span><span class="str">"~/Account/Login.aspx"</span><span class="pln"> timeout</span><span class="pun">=</span><span class="str">"3600"</span><span class="pln"> defaultUrl</span><span class="pun">=</span><span class="str">"~/"</span><span class="pln"> name</span><span class="pun">=</span><span class="str">""</span><span class="pln"> </span><span class="pun">/></span><span class="pln">
        </span><span class="pun"></</span><span class="pln">authentication</span><span class="pun">></span><span class="pln">
        </span><span class="pun"><</span><span class="pln">sessionState mode</span><span class="pun">=</span><span class="str">"InProc"</span><span class="pln"> cookieless</span><span class="pun">=</span><span class="str">"false"</span><span class="pln"> timeout</span><span class="pun">=</span><span class="str">"80"</span><span class="pln"> </span><span class="pun">/></span><span class="pln">
    
     </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="typ">User</span><span class="pln"> </span><span class="typ">User</span><span class="pln">
        </span><span class="pun">{</span><span class="pln">
            get
            </span><span class="pun">{</span><span class="pln">
                </span><span class="typ">User</span><span class="pln"> userLogin </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">null</span><span class="pun">;</span><span class="pln">
                </span><span class="kwd">object</span><span class="pln"> sessionVar </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Session</span><span class="pun">[</span><span class="pln">USERLOGIN</span><span class="pun">];</span><span class="pln">
                </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">sessionVar </span><span class="pun">!=</span><span class="pln"> </span><span class="kwd">null</span><span class="pun">)</span><span class="pln">
                </span><span class="pun">{</span><span class="pln">
                    userLogin </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="typ">User</span><span class="pun">)</span><span class="pln"> sessionVar</span><span class="pun">;</span><span class="pln">
                </span><span class="pun">}</span><span class="pln">
                </span><span class="kwd">return</span><span class="pln"> userLogin</span><span class="pun">;</span><span class="pln">
            </span><span class="pun">}</span><span class="pln">
            </span><span class="typ">set</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> </span><span class="typ">Session</span><span class="pun">[</span><span class="pln">USERLOGIN</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> value</span><span class="pun">;</span><span class="pln"> </span><span class="pun">}</span><span class="pln">
        </span><span class="pun">}</span></code></pre>


    Abgelegt unter: , , ,
    • IP-Adresse ist Registriert
Seite 1 von 1 (1 Treffer)

Regeln | Impressum