Sunday, 27 March 2022

Extended Logout in MVC 5

Extending logged in time as per user's choice.

Scenario: The ASP.NET MVC 5 web application is hosted in Azure WebApp WebConfig is set to timeout in 60 minutes of no requests made to the server as shown below

WebConfig:

<authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="60" slidingExpiration="true" name="MYAUTHDV" cookieSameSite="None" requireSSL="true" />
</authentication>

In the login screen, we would like to provide a CHECKBOX and if user ticks it and login, the webapp should not log them out for next 12 hours even if there is no activity.

enter image description here

So far, I have tried a javascript timer running on the _layoutpage.chtml and a local storage time value registered at loggged in time at the client side. The javascript timer will ping to the server every 20 minutes to keep the login alive. This is not always working for multiple reasons like browser, machine sleep mode, hard disk turnoff internet interruptions and other unknown reasons as well etc. There is also an issue we have to overcome regarding sliding expiration vs javascript pinging .https://ift.tt/1xWMQDA I am also open to solutions involving server handling as well. Hoping a client side solution will incur less modification in our existing app.



from Extended Logout in MVC 5

No comments:

Post a Comment