The first, thanks the friends in this forum has help me alot of to build the application website ASP.net C#.
at moment, I finish create the webapp ( at you can login with demo/demo), but I'm facing a problem is when i open the web, in about 4 minutes if I don't have any actions on page then click
on any link on website, it will reditect to login page.
My first move would be to show HttpContext.Current.Session.SessionID. If the value changed it would confirm you are loosing the session for some reason. If I remember it is written to the Windows log out of box or at worst you can activate that. Or
maybe you are using load balanced servers?
when i open the web, in about 4 minutes if I don't have any actions on page then click on any link on website, it will reditect to login page.
Have you restarted your app during this time?
Best regards,
Sam
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Forms Authentication is not based on session. It is managed via an authentication cookie. It is unlikely that the session is expiring. More likely that the forms authentication ticket is. Try setting a value for the forms auth timeout:
Description:
An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: The configuration section cannot contain a CDATA or text element.
Source Error: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers
running on the local server machine.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
My web hosted in hosting share internet, before in iis_application pool, idle timeout set is 5 minutes, last night I contact admin of hosting for request change idle timeout to 60 minutes, at moment I'm testing is website expire or not.
Member
11 Points
77 Posts
why web pages expire when do not active in about 4 minutes
Jun 08, 2020 02:13 AM|test0101|LINK
dear fiend
The first, thanks the friends in this forum has help me alot of to build the application website ASP.net C#.
at moment, I finish create the webapp ( at you can login with demo/demo), but I'm facing a problem is when i open the web, in about 4 minutes if I don't have any actions on page then click on any link on website, it will reditect to login page.
my web.config:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <configSections /> <appSettings /> <system.web> <httpRuntime executionTimeout="999999" /> <compilation debug="true" targetFramework="4.5.2" /> <trust level="Full" /> <authentication mode="Forms" /> <sessionState timeout="60"></sessionState> <customErrors mode="Off" defaultRedirect="" /> <machineKey validationKey="308A5193B77D18BB33F286DCC941A54331AE8D000104EAC1DB843D98B1CB457AF9A813B4D5D7D77220987AC8EA478401577194FC20E6CCE8ACEC159C5C59D754" decryptionKey="46C25F7D8BFDE6DAF886AEC2706EFA6A2706C43C752B69C82D5B13A29EA246C1" validation="SHA1" decryption="AES" /> </system.web> <system.webServer> <directoryBrowse enabled="true" /> <defaultDocument> <files> <clear /> <add value="default.aspx" /> <add value="Default.htm" /> <add value="Default.asp" /> <add value="index.htm" /> <add value="index.html" /> <add value="iisstart.htm" /> </files> </defaultDocument> </system.webServer> </configuration>
In my code I use masterpage (main.master) and session:
Login.cs
if user Login susscess:
HttpContext.Current.Session.Timeout = 60;
HttpContext.Current.Session["UserName"] = txtUserName.Text;
In main.master i use:
<asp:ScriptManager id="toolScriptManageer1" runat="server" EnableHistory="true" EnablePartialRendering="false" EnablePageMethods="true"> </asp:ScriptManager>
and in Main.master.cs:
protected void Page_Load(object sender, EventArgs e) { if (HttpContext.Current.Session["UserName"] == null) { Response.Redirect("~/login.aspx"); Context.ApplicationInstance.CompleteRequest(); } if (!IsPostBack) { DataTable dt = this.GetData(0); PopulateMenu(dt, 0, null); } }
Please help me
All-Star
48570 Points
18079 Posts
Re: why web pages expire when do not active in about 4 minutes
Jun 08, 2020 08:00 AM|PatriceSc|LINK
Hi,
My first move would be to show HttpContext.Current.Session.SessionID. If the value changed it would confirm you are loosing the session for some reason. If I remember it is written to the Windows log out of box or at worst you can activate that. Or maybe you are using load balanced servers?
Edit: for example https://stackoverflow.com/questions/829392/how-to-discover-the-reason-of-asp-net-application-restart or https://docs.microsoft.com/en-us/previous-versions/iis/6.0-sdk/ms525613(v%3Dvs.90) at the IIS level or https://docs.microsoft.com/en-us/aspnet/web-forms/overview/older-versions-getting-started/deploying-web-site-projects/logging-error-details-with-asp-net-health-monitoring-cs at the ASP.NET level.
Member
11 Points
77 Posts
Re: why web pages expire when do not active in about 4 minutes
Jun 08, 2020 08:06 AM|test0101|LINK
I hosting webapp in internet, do not use load balancing.
Contributor
3370 Points
1409 Posts
Re: why web pages expire when do not active in about 4 minutes
Jun 09, 2020 06:43 AM|samwu|LINK
Hi test0101,
Have you restarted your app during this time?
Best regards,
Sam
All-Star
194506 Points
28081 Posts
Moderator
Re: why web pages expire when do not active in about 4 minutes
Jun 09, 2020 07:07 AM|Mikesdotnetting|LINK
Change login.aspx to the page where the user logs in.
Member
110 Points
115 Posts
Re: why web pages expire when do not active in about 4 minutes
Jun 09, 2020 07:54 AM|Masterpiece88|LINK
Hi test0101,
Are you using shared hosting?
Member
11 Points
77 Posts
Re: why web pages expire when do not active in about 4 minutes
Jun 09, 2020 08:25 AM|test0101|LINK
- yesterday i restarted application pool.
- i host the web in hosting shared
Member
11 Points
77 Posts
Re: why web pages expire when do not active in about 4 minutes
Jun 09, 2020 09:11 AM|test0101|LINK
Hi
if I added this to web.config:
<
authentication
mode
=
"Forms"
>
<
forms
defaultUrl
=
"~/default.aspx"
loginUrl
=
"~/Login.aspx"
slidingExpiration
=
"true"
timeout
=
"60"
></
forms
>
</
authentication
>
it's apprear error:
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: The configuration section cannot contain a CDATA or text element.
Source Error:
An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
All-Star
194506 Points
28081 Posts
Moderator
Re: why web pages expire when do not active in about 4 minutes
Jun 09, 2020 11:54 AM|Mikesdotnetting|LINK
Check that you haven't mistakenly added some other characters to the web.config when you added that section.
Member
11 Points
77 Posts
Re: why web pages expire when do not active in about 4 minutes
Jun 09, 2020 04:48 PM|test0101|LINK
Hi friend
I edited web.config as below, don't use </forms> tag
But website expired in 5 minutes idle. You can see by login user/pass: demo/demo at mysite
Contributor
3370 Points
1409 Posts
Re: why web pages expire when do not active in about 4 minutes
Jun 11, 2020 01:52 AM|samwu|LINK
Hi test0101,
Can you view the error message in Event Viewer?
Best regards,
Sam
Member
11 Points
77 Posts
Re: why web pages expire when do not active in about 4 minutes
Jun 11, 2020 02:20 AM|test0101|LINK
Hi Friend
My web hosted in hosting share internet, before in iis_application pool, idle timeout set is 5 minutes, last night I contact admin of hosting for request change idle timeout to 60 minutes, at moment I'm testing is website expire or not.
this is seting hosting
Member
11 Points
77 Posts
Re: why web pages expire when do not active in about 4 minutes
Jun 11, 2020 03:34 AM|test0101|LINK
Dear friends
after request hosting administrator change idle timeout in iis_application pool to 60, my web don't expire after 5 minutes.
Thanks all friends very much!!!