Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have use the following code in webconfig

XML
<configuration>
   <system.web>
    <sessionState mode="InProc" timeout="20" />
    </system.web>
</configuration>



how ever after 5 min. of inactivity my page showing the following error


XML
Server Error in '/' Application.

Runtime Error

Description: 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.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".


<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.


<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>



my question is how to increase the session timeout time.
Posted

1 solution

There are a few things here: the first is pretty obvious.
Look at the error message: it does not say that it's the session length that is causing the problem, it says it can't tell you what the problem is, and explains exactly how to enable things so you can find out exactly what the problem is! So the first thing to do is to read it carefully, and follow the instructions before running your site again. This time, you should get "real" information as to why it failed, rather than guessing that it's the session expiry that causes the problem.

Secondly, the default session length (unless overridden by your web hosting service) is twenty minutes, and it is very unadvisable to change it.
If your session is expiring after five minutes, then it's being overridden by the hosting service, and you need to talk to them to increase it - nothing you can do will override what they have explicitly told IIS to do.
 
Share this answer
 
Comments
BIBASWAN 4-Nov-15 5:58am    
i have already test it and its causing for session timeout.by the way your solution help me quite.thnx
BIBASWAN 4-Nov-15 6:00am    
yes you r right sir,hosting service overridde it to 5 mins.now please tell me in that case what should i do?
OriginalGriff 4-Nov-15 6:19am    
You have to talk to the hosting service - they may be able to change it for you, but there is nothing you can do in your code to override their maximum setting.

The only other alternative is to stop using the session completely, and use Cookies instead.
BIBASWAN 19-Mar-16 1:27am    
sir i have use Cookies my application
here is my code

private void CheckCookie()
{
HttpCookie CookieName = Request.Cookies["MyCookie"];
CookieName.Expires = DateTime.Now.AddMinutes(30);
if (CookieName != null)
{
Uid = Request.Cookies["MyCookie"]["UserId"];
UTyp = Request.Cookies["MyCookie"]["UserType"];
UName = Request.Cookies["MyCookie"]["name"];
ArrangerId = Request.Cookies["MyCookie"]["ArrangerId"];
}
}


protected void Page_Load(object sender, EventArgs e)
{
try
{
CheckCookie();
}
catch (Exception ex)
{
string s = ex.Message;
Response.Redirect("logout");
}
}


but the problem remain same....
AdamASPGeek 16-Nov-15 4:16am    
Yeap... You can't use session on shared hosting as it will impact to other client sites on their server. You need to use cookies or asp.net session state.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900