不可发音成员'Http SessionState.Timeout'不能像方法一样使用

问题描述 投票:-2回答:1
 protected void Button1_Click(object sender, EventArgs e)
    {
        Session["Email"] = "[email protected]";
        Session.Timeout("200"); 

不可发音成员'Http SessionState.Timeout'不能像方法一样使用

    }

如何解决此问题?

    protected void Button2_Click(object sender, EventArgs e)
    {
        if (Session["Email"] !=null)
        {
            Email.Text = Session["Email"].ToString;

        }
        else
        {
            Email.Text = "Please Set Session";

        }
    }
c#
1个回答
0
投票

错误消息很清楚:“这不是一个功能。请停止尝试像使用它一样。”

即使不看课,我也可以猜测超时将是一个字段或属性。尽管属性只是用于获取/设置函数对的语法糖,但在所有情况中,有95%的属性像任何普通字段一样使用。这就是语法糖的用途。

我也在猜测超时不是字符串属性/字段。因此,字符串"200"仍然是错误的输入。

因此,在两种情况下,正确的行是:

Session.Timeout = 200;

编辑:已确认。 It is a property. And a Integer one.

© www.soinside.com 2019 - 2024. All rights reserved.