<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ASP.Net Development Company in India &gt; Metasys Software Pvt Ltd.</title>
	<atom:link href="https://ikfstage.metasyssoftware.com/tag/asp-net-development-company-in-india/feed/" rel="self" type="application/rss+xml" />
	<link>https://ikfstage.metasyssoftware.com</link>
	<description></description>
	<lastBuildDate>Thu, 20 Jul 2023 10:21:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>How to Keep an Application Logged in to Avoid Session Timeout and Data Loss (Asp.net)?</title>
		<link>https://ikfstage.metasyssoftware.com/microsoft-technologies/how-to-keep-an-application-logged-in-to-avoid-session-timeout-and-data-loss-asp-net/</link>
		
		<dc:creator><![CDATA[meta_prasad]]></dc:creator>
		<pubDate>Thu, 06 Jul 2023 05:56:43 +0000</pubDate>
				<category><![CDATA[Microsoft Technologies]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.Net Development Company in India]]></category>
		<guid isPermaLink="false">https://development.ikf.in/metasys1/?p=6256</guid>

					<description><![CDATA[<p>Session Management is an important aspect to be taken care of while writing code. Several factors play a role in deciding your strategy and it is never one size fits all. It is important to understand the context and specific requirements of a business to determine the appropriate session duration. In this context, the application &#8230;</p>
<p class="read-more"> <a class="" href="https://ikfstage.metasyssoftware.com/microsoft-technologies/how-to-keep-an-application-logged-in-to-avoid-session-timeout-and-data-loss-asp-net/"> <span class="screen-reader-text">How to Keep an Application Logged in to Avoid Session Timeout and Data Loss (Asp.net)?</span> Read More &#187;</a></p>
The post <a href="https://ikfstage.metasyssoftware.com/microsoft-technologies/how-to-keep-an-application-logged-in-to-avoid-session-timeout-and-data-loss-asp-net/">How to Keep an Application Logged in to Avoid Session Timeout and Data Loss (Asp.net)?</a> appeared first on <a href="https://ikfstage.metasyssoftware.com">Metasys Software Pvt Ltd.</a>.]]></description>
										<content:encoded><![CDATA[<div id="pl-6256"  class="panel-layout" ><div id="pg-6256-0"  class="panel-grid panel-no-style" ><div id="pgc-6256-0-0"  class="panel-grid-cell" ><div id="panel-6256-0-0-0" class="so-panel widget widget_sow-editor panel-first-child panel-last-child" data-index="0" ><div
			
			class="so-widget-sow-editor so-widget-sow-editor-base"
			
		>
<div class="siteorigin-widget-tinymce textwidget">
	<p>Session Management is an important aspect to be taken care of while writing code. Several factors play a role in deciding your strategy and it is never one size fits all. It is important to understand the context and specific requirements of a business to determine the appropriate session duration.</p>
<p>In this context, the application was used as an internal application to gather data on all the work being completed by the construction crew. This was reviewed by the managers and supervisors and thereafter billers generated the invoices.</p>
<p>It was important here to allow for long session durations. The users wanted the ability to remain logged in even when the application might be idle for a long time, and with no data loss. This would not be recommended in the context of personal banking, where security and avoidance of session hacking are of far greater importance.</p>
<p>This article explains how you can maintain a session in ASP.Net and avoid getting logged out, even when the application is idle for a long time. This method will also help in preventing data loss.</p>
<p>We used Handler to maintain the session in ASP.Net.</p>
<p><h2><strong>Why Handler?</strong></h2>
</p>
<ul>
<li>Handler makes a simple post-back call to the server to keep the session alive.</li>
<li>In Handler, a session variable is accessed only if it is inherited by the interface IRequiresSessionState. The handler receives the request from the aspx page and, in turn, sends a response.</li>
</ul>
<p><strong>Implementation of Handler in our application using Asp.net and jQuery:</strong></p>
<p>We employ Handler in our application for user data maintenance and to prevent session time out.</p>
<p><strong>How Handler Works:</strong></p>
<ul>
<li>Create a handler by right-clicking on the website and adding an item by selecting a generic handler.  Eg:(KeepActive.ashx) - extension of handler is ASHX.</li>
<li>Make a call to the handler using jQuery function.</li>
</ul>
<p><strong>Code snippet:</strong></p>
<p><%@ WebHandler Language="C#" Class="KeepActive" %><br />
using System;<br />
using System.Web;<br />
using System.Web.SessionState;<br />
public class KeepActive : IHttpHandler, IRequiresSessionState<br />
{<br />
    public void ProcessRequest(HttpContext context)<br />
    {<br />
        try<br />
        {<br />
            context.Session["Active"] = DateTime.Now;<br />
        }<br />
        catch { }<br />
    }<br />
  }<br />
    public bool IsReusable<br />
    {<br />
        get<br />
        {<br />
            return false;<br />
        }<br />
    }<br />
}
</p>
<ul>
<li>After the handler is created, create a jQuery function named “setinterval”, which runs at an    interval to update session.</li>
<li>Please find the below jQuery code, which is called on load of the page and it has a function named “setinterval”, which get triggered after every five minutes:</li>
</ul>
<p><strong>Code snippet:</strong></p>
<p>window.onload = function () {<br />
var idleInterval = setInterval(timerIncrement, 300000); // for 5 minutes<br />
}</p>
<ul>
<li>The above function calls another function named “timerIncrement”, which triggers and calls handler named “KeepActive” after every five minutes. It is necessary to update the session and keep it alive</li>
</ul>
<p><strong>Code snippet:</strong></p>
<p>function timerIncrement() {<br />
idleTime = idleTime + 1;<br />
if (idleTime &gt; 1) { // Greater than 10 minutes<br />
if (typeof GetHiddenForemanReportID == 'function') {<br />
var foremanReportID = GetHiddenForemanReportID();<br />
jq.post("/KeepActive.ashx?foremanReportID=" + foremanReportID, null,     function () {<br />
});</p>
<p>MetaSys Software’s developers have successfully delivered applications using <a href="https://development.ikf.in/metasys1/case-study-dotnet">ASP.Net Core</a> and .Net &amp; ASP.Net Framework. For more details, see <a href="https://development.ikf.in/metasys1/dot-net">https://development.ikf.in/metasys1/dot-net</a>. <a href="https://development.ikf.in/metasys1/contact/">Contact us</a> with your project requirements now!</p>
</div>
</div></div></div></div></div>The post <a href="https://ikfstage.metasyssoftware.com/microsoft-technologies/how-to-keep-an-application-logged-in-to-avoid-session-timeout-and-data-loss-asp-net/">How to Keep an Application Logged in to Avoid Session Timeout and Data Loss (Asp.net)?</a> appeared first on <a href="https://ikfstage.metasyssoftware.com">Metasys Software Pvt Ltd.</a>.]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
