English 中文(简体)
页: 1
原标题:session variables timeout in asp.net app

在我的网页上使用一些会议变量的Im,这些变量在I日志中确定:

e.g. Session("user_id") = reader("user_id")

我用了这个话。

当会议变时,这主要在将数据库连接为<代码>session(“用户_id”)时留下错误。

我如何确定本届会议的变数,以便一旦时间到正文页,或如何能够至少增加可用时间?

最佳回答

我猜想你重新使用认证表格。 这里的陷阱是,确保你的发言形式在届会之前到期。

我在此答复中写道:

How to redirect tologIn page when Session is 164 (ASP)。 NET 3.5 FormsAuthen

例如:

发言时间为60分钟。

<authentication mode="Forms">
    <forms defaultUrl="~/Default.aspx"
        loginUrl="~/Login.aspx"
        slidingExpiration="true"
        timeout="60" />
</authentication>

1. 延长会期:

<sessionState 
    mode="InProc" 
    cookieless="false" 
    timeout="70"/>

http://www.ohchr.org。 您的代码也可使用<代码>Session.Clear();,在分配会议价值之前删除会期数据。

问题回答

以往,我用一个基页或每个网页上的总页(为日志页设定一个例外),该网页读上了一段话,以证明目前用户是否被贴上标签。

如果它永远是一纸空文,它就可节省目前的圆顶,并改用日志。

After logging in it reads the saved url and redirects the user back to the requested page.

提高会议时间分配值是国际会计准则的一个环境。

How can I set my session variables so that once they are timed out to go to the login page

如果是<代码>Response.Redirect(“Home.aspx”);

or how can at least increase the length of time the are available?

http://msdn.microsoft.com/en-us/library/h6bb9cz 928v=vs.71%29.aspx”rel=“nofollow” 要素

我认为,许多人在总结会议时呼吁提供一种“气载”模式。 与此类似:

class SessionHelper
{
    public static string GetUserId()
    {
        string userId = (string)System.Web.HttpContext.Current.Session["UserId"];

        if( userId == null )
        {
           userId = reader("UserId");
           System.Web.HttpContext.Current.Session["UserId"] = userId;
        }

        return userId;
    }
}




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签