Session Exclusion and Exclusion

I have a problem with session expiration. Firstly, it expires every 20 minutes and it gives an error ...

I tried to fix this:

if (Session["userName"].ToString() == null)
{
   Session.RemoveAll();
   Response.Redirect("~/Login.aspx?sessionError=" + "*Session Expired on pageload PleaseLog in again");
}

But I get the following error:

The reference to the object is not installed in the instance of the object.

My stack trace:

[NullReferenceException: the reference to the object was not installed in the instance of the object.] CopiunGUI.Site1.checksession () in C: \ Users \ jagmit \ Documents \ Visual Studio 2008 \ Projects \ copiunGUI \ copiunGUI \ Site1.Master.cs: 224 copiunGUI .Site1.TreeViewMain_Unload (object sender, EventArgs e) in C: \ Users \ jagmit \ Documents \ Visual Studio 2008 \ Projects \ copiunGUI \ copiunGUI \ Site1.Master.cs: 210 System.Web.UI.Control.OnUnload (EventArgs e ) +8681754 System.Web.UI.Control.UnloadRecursive (Boolean dispose) +252 System.Web.UI.Control.UnloadRecursive (Boolean dispose) +188 System.Web.UI.Control.UnloadRecursive (Boolean dispose) +188 System. Web.UI.Control.UnloadRecursive (Boolean dispose) +188 System.Web.UI.Control.UnloadRecursive (Boolean dispose) +188 System.Web.UI.Page.UnloadRecursive (Boolean dispose) +23 System.Web.UI.Page .ProcessRequestCleanup () +43

My web.config:

<authentication mode="Forms">
    <forms loginUrl="Login.aspx" defaultUrl="~/Default.aspx" name="Cookie" timeout="10080" path="/">
    </forms>
</authentication>
<authorization>
    <deny users="?"/>
    <allow users="*"/>
</authorization>

, .......

, ...

:

if (Session["userName"] == null)
{
   Session.RemoveAll();
   Response.Redirect("~/Login.aspx?sessionError=" + "*Session Expired on pageload PleaseLog in again");
}

:

.

+3
7

:

if (Session["userName"].ToString() == null)

Session [ "UserName" ] , .ToString().

...

if (Session["userName"] == null)...
+9

.ToString() , (- )

. :

if (String.IsNullOrEmpty(Session["userName"]))
    {
        Session.RemoveAll();
        Response.Redirect("~/Login.aspx?sessionError=" + "*Session Expired on pageload PleaseLog in again");
    }
+2

.

String.IsNullOrEmpty(Session [ "_" ])

. 20 , . . javascript ping- 15 , , . .

+1

, :

if (Session["userName"] == null)
{
     Session.Abandon();
     Response.Redirect("~/Login.aspx?sessionError=" + "*Session Expired on pageload PleaseLog in again", true);
}

, , null . . , true Response.Redirect, , . , Session.Abandon();, , , , RemoveAll, .

, Response , , . .

+1

- QA-. - IIS 20 , web.config. .

-

String.IsNullOrEmpty [ "userName" ]

, -

0

" ", .

TreeView :

.

, - Server.Transfer .

Kelsey , - , (, PageLoad, ).

, , , , : , cookie , " " , , "" ( ) :

<sessionState timeout="60" /> 
0

525601, , . , .

-2

Source: https://habr.com/ru/post/1725001/


All Articles