How to increase waiting time Session asp.net c #

3

Good I'm doing my project so that lasts 2 hours the session is to say an example. that if the user enters and leaves after 2 hours, it should not be closed. Currently every time that 45 minutes passes when the client makes or goes to another tab, he is redirected to the login.

I would like that after 2 hours that is done. increase the session time.

Global.asax

  protected void Application_Start(object sender, EventArgs e)
    {

    }

    protected void Session_Start(object sender, EventArgs e)
    {
        Session["username"] = "username";

        Session.Timeout = 5000;
    }

    protected void Application_BeginRequest(object sender, EventArgs e)
    {

    }

    protected void Application_AuthenticateRequest(object sender, EventArgs e)
    {

    }

    protected void Application_Error(object sender, EventArgs e)
    {

    }

    protected void Session_End(object sender, EventArgs e)
    {

    }

    protected void Application_End(object sender, EventArgs e)
    {
        Session.Abandon();
    }

WebConfig.

<configuration>
  <appSettings>
    <!--<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;"/>-->
    <!-- <add key="ChartImageHandler" value="storage=file;timeout=20;" />-->
    <add key="ChartImageHandler" value="storage=file;timeout=20;deleteAfterServicing=false;privateImages=false" />
    <add key="ChartImageHandler" value="storage=memory;deleteAfterServicing=true;"/>
  </appSettings>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
      <remove name="ChartImageHandler" />
      <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST"
        path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </handlers>
  </system.webServer>
  <system.web>
    <sessionState mode="InProc" timeout="525600"></sessionState>

    <customErrors mode="Off"/>

    <httpHandlers>
      <add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        validate="false" />
    </httpHandlers>
    <pages>
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
          assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </controls>
    </pages>
    <compilation debug="true" targetFramework="4.5.2">
      <assemblies>
        <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </assemblies>
    </compilation>
    <httpRuntime targetFramework="4.5.2" executionTimeout="9000000" maxRequestLength="999999999"/>
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="Ws_UsuarioSoap" sendTimeout="20.00:00:00" maxBufferSize="999999980"
          maxReceivedMessageSize="999999980" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:65213/Ws_Usuario.asmx" binding="basicHttpBinding"
        bindingConfiguration="Ws_UsuarioSoap" contract="Ws_Usuario.Ws_UsuarioSoap"
        name="Ws_UsuarioSoap" />
    </client>
  </system.serviceModel>
</configuration>

in all my page in the load are like this. that is, if the session is the same username is redirected to the login

 protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["username"].ToString() == "username")
            { Response.Redirect(Page.ResolveUrl("~") + @"Seguridad/CerrarSession.aspx"); }

            if (!Page.IsPostBack)
            {
                llenarGrilla();
            }
        }
    
asked by PieroDev 06.08.2018 в 23:32
source

1 answer

0

The time is in seconds, so you can put that number

<configuration>
  <system.web>
     <sessionState timeout="7200"></sessionState>
  </system.web>
</configuration>
    
answered by 07.08.2018 в 16:02